Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Barnskis Winsock and Lua Library now available!

Author
Message
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 5th Jul 2007 16:54 Edited at: 6th Jul 2007 21:47
Hello DarkGDK users!

I finally release an unmanaged c++ library version of my WinsockPlugin and my LuaPlugin.

See Program announcements for the threads of the plugins:BarnskisWinsockPlugin
BarnskisLuaPlugin

The download pack contains the library and the header file used for the DBPro plugin. It uses the C export style and stuff to make it work with DBPro, so it might look a bit awkward compared to normal c++ programming interfaces.

The libraries are compiled with MS VS C++ 2005 SP1 and the Multi-threaded Debug setting (statically linked runtime).

An online help is available which explains all commands in detail, however it is tailored for the DBPro Plugin version. Most commands are named pretty equal, so it should not matter (except for the datatypes).

The page on which you can download and see all information about my plugins can be found in my signature.

These libraries are released for free if you plan a non-commercial distribution. Otherwise please send me an email (also to get the release versions) thanks!

And please tell me your experiences when using it.
For library related stuff (help on including into your project) ask here, for bugs within the library please post in the apropriate program announcement thread.

If you like me to make a managed c++ library version to use it with DGDK.NET then I need help on that

CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 5th Jul 2007 17:11


"In the event that I am reincarnated, I would like to return as a deadly virus, in order to contribute something to solve overpopulation" Prince Philip 1988
tparkin
17
Years of Service
User Offline
Joined: 28th Mar 2007
Location:
Posted: 5th Jul 2007 18:30
Great work. This will surely be useful.

Thanks for sharing.
Jna99
19
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 5th Jul 2007 19:44 Edited at: 5th Jul 2007 19:44
Really Great work Barnski , I've been waiting for sometime to use LUA in my games, it opens a lot of doors...Thks

Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 6th Jul 2007 15:47
Who can make a version for DGDK.NET ???

Niels Henriksen
Working on a (MMO)RPG right now in DarkEngine
http://www.tigernet.dk - Send SMS to mobile online (will come in english soon)
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 6th Jul 2007 16:03
Thanks for your comments, and for even stickying the thread

I am working on an example to show how to use the libraries within c++. As a side effect I will be updating the library pack. As I did just now silently.

Here is the answer to two questions of user "Try" from the Program Announcement board, which I prefer to answer here, as I don't want to confuse DBPro users with c++ related stuff.

Quote: "Q1: I'm using DGDK, I've included your .h and .lib files but when I try using it (for example just the make()) I get some errors

Q2: btw, I didn't completely get it; the call of DBP commands are just for the DBP Plug-in (the one your made) or DGDK users can use DGDK commands either? (because I saw a table command or something like that, is it right?) "

A1: I updated the library download pack (silently) with a new .h file that should work for you. If you still have problems concerning the linking of the library please post them!
Besides, I recommend including the header file within a namespace, as follows:
Quote: "
#include <windows.h>
#include <stdio.h>
namespace ws {
#include "winsock_plugin.h"
}
"

Then you can access all commands by using ws:: and you should then see the auto-complete list. I changed the layout of the header file to make the comments visible for each function, to further ease the use for the developer.

A2: The DBPro.Call and DBPro.CallEx functions for lua scripts are only for usage with DBPro. When calling the lua make function to initialize the library, you should specify a flag with value 0, such that this table is not created.
If you want to use DGDK commands from within your scripts, you will have to manually register them within lua. But there is no such command yet.

Currently, I am working with winsock to make a (rather extended) example. I might look at implementing such a register function later on.

Quote: "
Who can make a version for DGDK.NET ??? "


If anyone can tell me or point me to directions on how to make one, I will gladly do it.

Thanks,
Barnski.

Try
20
Years of Service
User Offline
Joined: 16th Aug 2004
Location:
Posted: 6th Jul 2007 16:42
@Barnski:
Quote: "Currently, I am working with winsock to make a (rather extended) example. I might look at implementing such a register function later on."

Thanks man, I'm waiting for 'calling DGDK commands' feature.

Well, it seems that I'm doing something wrong!


Help please!
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 6th Jul 2007 19:14
Quote: "Well, it seems that I'm doing something wrong!"


Actually, I did something wrong with the lib export and constant definition when compiling.

I have updated both library packs with new lib versions and header files.

The functions returning a string (char*) are now mapped for c++ to be LPSTR (char*), so they can be used now.

Please download and try again "Try"

Try
20
Years of Service
User Offline
Joined: 16th Aug 2004
Location:
Posted: 6th Jul 2007 19:44
@Barnski:
Are you sure that you've uploaded the latest version? I'm still getting the same error!

btw, why don't you increase the versioning?

Waiting...
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 6th Jul 2007 20:41
Barnski,

I stickied the thread as it looked like a very useful plugin. I read that people are wanting to use the plugin with DGDK.NET possibly. To create a plugin for DarkGDK.NET, you need to create a managed C++ class library where by you create a managed class that acts as a thunk layer between your main C++ code, and .NET.

The DarkGDK.NET toolkit (if you have it), comes with two samples, both VB and C#, that demonstrates how to build plugins for the toolkit. THe samples are very simple, and yet they demonstrate the principles in creating a managed class library which interfaces with your C++ code. It is important to note that to protect your code from be decompiled, make sure that you keep the managed class as an interface class, and your own C++ code in a separate unmanaged object file.

If you need further assistance with creating your plugin, I'll be able to assist.

Cheers.

Paul.

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 6th Jul 2007 21:45 Edited at: 6th Jul 2007 21:49
Thanks APEXnow, its nice to hear people like to use my plugins.

once the c++ library versions are working fine and my example is finished, I will have a look at making a managed lib version.

Actually I dont have the DarkGDK.NET toolkit. That means I wont be able to test it.
Quote: "If you need further assistance with creating your plugin, I'll be able to assist.
"

I will surely have to come back to that.

For now; I uploaded new build versions of the library packs again. 20:30).
Empty your browsers cache to make sure you get the new files.
The version is the same because I want to keep the library and the plugin on the same version. However, I introduced a build number which can be looked at in the change log. its build 8.

The changes are:
I added namespace to the libraries: ws and lua.
This allows to use both libraries at the same time.
I further made them compatible with the latest upgrade of DarkGDK.
The functions are no more exported as "C".

The lua function "make" behaves differently than the dbp plugins "lua make", as it doesnt create the dbpro table (and there is no possibility for a flag).

"Try", I hope it works for you now too!

Thats it for today, thanks and see you tomorrow

edit: advantage of namespaces:


Try
20
Years of Service
User Offline
Joined: 16th Aug 2004
Location:
Posted: 6th Jul 2007 22:21 Edited at: 6th Jul 2007 22:22
@Barnski:
Oh, man...
I'm using the latest version of you lua plug-in.(Build 8)

But...


Do I have to have lua libraries or something like that?!!! (anything I missed?)
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 6th Jul 2007 22:38
Checklist
1. Use Visual Studio C++ 2005 Service Pack 1 or Express Edition.
2. Project settings: "Multi-threaded Debug"
3. Include dir: add the directory where you unzipped the lua_plugin.h file. #include "lua_plugin.h"
4. Library dir: add the directory where you unzipped the "Barnski'sLuaPlugin_debug.lib".
5. Add the Library "Barnski'sLuaPlugin_debug.lib" to the lib dependencies.

And always make sure to have the newest version (already updated to build 10)

You don't need the lua.lib, as it is statically included in my library already.

If you have all that done, maybe give more details on your code and project settings.

Try
20
Years of Service
User Offline
Joined: 16th Aug 2004
Location:
Posted: 7th Jul 2007 02:16 Edited at: 7th Jul 2007 02:18
@Barnski:
Quote: "5. Add the Library "Barnski'sLuaPlugin_debug.lib" to the lib dependencies."

Uhha, the only thing that I forgot, that did the trick. (stupid me )

Quote: "already updated to build 10"

Tell me that you're gonna work on DGDK calls, oh, come on... (j/k I know you're working on the other one)

Thanks anyway man, can't wait to see more from you.
mhack2
21
Years of Service
User Offline
Joined: 10th Oct 2003
Location: USA, Earth, Sol[0,0]
Posted: 12th Jul 2007 17:01
Did anybody get the Winsock lib to work under C++?

I tried to do Chat Server, and it worked fine to send data and get connections, but I can't get any input strings from the clients?

Each time a client sends a string "Hello" I get "data is waiting" and then zero sized string "" in return?

I also noticed that channel_data_len is also 0 at this point?

What the..?

Strings are LPSTRs.

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 12th Jul 2007 17:07
@mhack2
Which commands are you using to send and retrieve the string?

Could you show me your code?

LPSTR is char*, or std::string::c_str()

I changed the interface for the library since it works different for strings in DBP.
If you could give me an example code which I can use to reproduce the mistake I could fix the problem quicker (or your code).

Thanks.

mhack2
21
Years of Service
User Offline
Joined: 10th Oct 2003
Location: USA, Earth, Sol[0,0]
Posted: 12th Jul 2007 18:16
No problem, I will post the code today,

But I just converted your DBP "Chat Server" example, same commands as there..

I think "ws::recv_..string" is getting empty string or no string at all.

I'm using it with

LPSTR buffer;
size_t buffer_size = 512;

buffer new char(buffer_size);

LPSTR message = ws::recv_..string(client_channel, buffer, buffer_size)

something like this (by memory)

But when I send messages like "client_1 connected" clients get those. But server only gets requests.

I'm using converted "Chat Server" compiled with C++ and DBP version of "Chat Client" exe - could this be a problem?

BTW, did you do any tests with C++?

mhack2
21
Years of Service
User Offline
Joined: 10th Oct 2003
Location: USA, Earth, Sol[0,0]
Posted: 12th Jul 2007 20:18
Ok, here is my code, please excuse the debug variables etc.
I converted you "Chat Server" DBP example. I'm using this with DBP compiled Chat client exe.

I also have a problem setting Multi-threaded debug, using just Multi-threaded seems ok.

Just copy it and run it. Let me know if I do something wrong..




This gets the connection of the client, switches to new port/channel but doesn't get the string from the client..
But it sends strings to the client(s) ok.
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 12th Jul 2007 22:34 Edited at: 12th Jul 2007 22:39
Thanks for the code. You did a good job on translating my dbpro chat server example. It will serve well as an example for others.


However, you missed one important line, that made your version fail:

ws::recv_message(channel);

If there is data waiting on a channel, first use this command to load the data into the internal buffer of the library. Then you can retrieve it from there using ws::recv_string().

For DarkGDK projects where you want to use Multi-threaded Debug mode, you need to use the debug libraries of the DGDK. They can be found in a separate folder inside the Lib folder of the installation path (VC8debug, instead of VC8).

By the way, for the server, now that it is in C++, you don't need to use DarkGDK anymore... instead you can run a console app.

And for the string printing, there are several options;
either define a buffer and use sprintf(), or use std::string and append() of class string.

NEVER use dbStr() without assigning it to a char* (or LPSTR) variable! Because you need to delete[] the memory afterwards!

Quote: "BTW, did you do any tests with C++?"

Yes, but I did not test all commands. Currently, I am working on a project using winsock library, but no string sending / receiving. Only UDP messages, defined as structs.
Thanks to my working with my own lib I missed some commands I needed so I have already added new commands which I will release in the next version... stay tuned

edit; the receive buffer should be at least 8192 bytes. The error buffer can be 256. But 512 is better, if I decide to change it But you can specify your buffer sizes, so no errors should occurr.

mhack2
21
Years of Service
User Offline
Joined: 10th Oct 2003
Location: USA, Earth, Sol[0,0]
Posted: 12th Jul 2007 23:13
Thanks for checking the code, I hope it works, will try it tonight.

Great lib BTW, thank you!

I guess this is my first contribution to DB community

My project will be heavy UDP but I wanted to start playing with your lib so I started with TCP.
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 8th Sep 2007 17:35
How does it look with Lua in DGDK.NET?

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine
http://noggs.netopcom.dk/forum/default.asp - Forum for the game
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 13th Sep 2007 12:34
Quote: "How does it look with Lua in DGDK.NET?"

Thanks for reminding me.
I was working on a major winsock update but I had to stall it for other work, which is still taking up my daily programming time. Hey, I finally get payed for programming a game
In a few weeks I will look at how to make c++ dlls available for .NET.
I guess I don't need DGDK.NET, I will just make it work for .NET, and the work of including it into your DGDK.NET project shouldnt be too difficult then. Maybe there is already a way to include it without me doing anything...

Anyways, thanks for the ongoing interest, and stay tuned

Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 15th Sep 2007 11:07
Quote: "Thanks for reminding me."


No problem... Im waiting for it because it will be more easy for me to make the game

Im trying to see how they do in WoW with Lua and thats interesting. But I think that a Lua.NET not only can be used in DGDK.NET but also in other programs.

I'm getting ideas now...

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine
http://noggs.netopcom.dk/forum/default.asp - Forum for the game

Login to post a reply

Server time is: 2024-11-16 20:35:59
Your offset time is: 2024-11-16 20:35:59