The Game Creators
The Game Creators Home Click to Login
  Hot: Official TGC CompetitionLee is tweeting!July NewsletterSmart PackerBox2DWeb Hosting SurveyDGS BonanzaFPS Creator Bonanza;
The Game Creators
Dark GDK / Barnskis Winsock and Lua Library now available!

Go to the first page of this board Return to the Forum Menu Post Message
23 Messages - Page   of 1   
Bookmark and Share Search the Forum

Author Message
Barnski

User


Joined: Thu Jan 26th 2006
Location: Switzerland, Zurich
Posted: 5th Jul 2007 08:54     Edited: 6th Jul 2007 13:47     | link | toggle

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

Back to top
MyWinsockPlugin
Report this message as abusive
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 5th Jul 2007 09:11           | link | toggle



"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
Back to top
Report this message as abusive
tparkin

User


Joined: Wed Mar 28th 2007
Location: Cyberspace
Posted: 5th Jul 2007 10:30           | link | toggle

Great work. This will surely be useful.

Thanks for sharing.
Back to top
Report this message as abusive
Jna99

User


Joined: Thu Nov 3rd 2005
Location: Portugal
Posted: 5th Jul 2007 11:44     Edited: 5th Jul 2007 11:44     | link | toggle

Really Great work Barnski , I've been waiting for sometime to use LUA in my games, it opens a lot of doors...Thks

Back to top
Report this message as abusive
Niels Henriksen

User


Joined: Mon Sep 27th 2004
Location: Behind you breathing heavely
Posted: 6th Jul 2007 07:47           | link | toggle

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)
Back to top
Netopcom Webhosting Find user on ICQ
Report this message as abusive
Barnski

User


Joined: Thu Jan 26th 2006
Location: Switzerland, Zurich
Posted: 6th Jul 2007 08:03           | link | toggle

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.

Back to top
MyWinsockPlugin
Report this message as abusive
Try

User


Joined: Mon Aug 16th 2004
Location: Cyberspace
Posted: 6th Jul 2007 08:42           | link | toggle

@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!
+ Code Snippet

Help please!
Back to top
Report this message as abusive
Barnski

User


Joined: Thu Jan 26th 2006
Location: Switzerland, Zurich
Posted: 6th Jul 2007 11:14           | link | toggle

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"

Back to top
MyWinsockPlugin
Report this message as abusive
Try

User


Joined: Mon Aug 16th 2004
Location: Cyberspace
Posted: 6th Jul 2007 11:44           | link | toggle

@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...
Back to top
Report this message as abusive
APEXnow

DarkGDK .NET Developer


Joined: Tue Apr 15th 2003
Location: On a park bench
Posted: 6th Jul 2007 12:41           | link | toggle

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.

Back to top
APEXnow
Report this message as abusive
Barnski

User


Joined: Thu Jan 26th 2006
Location: Switzerland, Zurich
Posted: 6th Jul 2007 13:45     Edited: 6th Jul 2007 13:49     | link | toggle

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:
+ Code Snippet

Back to top
MyWinsockPlugin
Report this message as abusive
Google Ad
Back to top
 
Try

User


Joined: Mon Aug 16th 2004
Location: Cyberspace
Posted: 6th Jul 2007 14:21     Edited: 6th Jul 2007 14:22     | link | toggle

@Barnski:
Oh, man...
I'm using the latest version of you lua plug-in.(Build 8)

But...
+ Code Snippet

Do I have to have lua libraries or something like that?!!! (anything I missed?)
Back to top
Report this message as abusive
Barnski

User


Joined: Thu Jan 26th 2006
Location: Switzerland, Zurich
Posted: 6th Jul 2007 14:38           | link | toggle

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.

Back to top
MyWinsockPlugin
Report this message as abusive
Try

User


Joined: Mon Aug 16th 2004
Location: Cyberspace
Posted: 6th Jul 2007 18:16     Edited: 6th Jul 2007 18:18     | link | toggle

@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.
Back to top
Report this message as abusive
mhack2

User


Joined: Fri Oct 10th 2003
Location: USA, Earth, Sol[0,0]
Posted: 12th Jul 2007 09:01           | link | toggle

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.

Back to top
Report this message as abusive
Barnski

User


Joined: Thu Jan 26th 2006
Location: Switzerland, Zurich
Posted: 12th Jul 2007 09:07           | link | toggle

@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.

Back to top
MyWinsockPlugin
Report this message as abusive
mhack2

User


Joined: Fri Oct 10th 2003
Location: USA, Earth, Sol[0,0]
Posted: 12th Jul 2007 10:16           | link | toggle

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++?

Back to top
Report this message as abusive
mhack2

User


Joined: Fri Oct 10th 2003
Location: USA, Earth, Sol[0,0]
Posted: 12th Jul 2007 12:18           | link | toggle

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..

+ Code Snippet


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.
Back to top
Report this message as abusive
Barnski

User


Joined: Thu Jan 26th 2006
Location: Switzerland, Zurich
Posted: 12th Jul 2007 14:34     Edited: 12th Jul 2007 14:39     | link | toggle

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.

Back to top
MyWinsockPlugin
Report this message as abusive
mhack2

User


Joined: Fri Oct 10th 2003
Location: USA, Earth, Sol[0,0]
Posted: 12th Jul 2007 15:13           | link | toggle

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.
Back to top
Report this message as abusive
Niels Henriksen

User


Joined: Mon Sep 27th 2004
Location: Behind you breathing heavely
Posted: 8th Sep 2007 09:35           | link | toggle

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
Back to top
Netopcom Webhosting Find user on ICQ
Report this message as abusive
Barnski

User


Joined: Thu Jan 26th 2006
Location: Switzerland, Zurich
Posted: 13th Sep 2007 04:34           | link | toggle

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

Back to top
MyWinsockPlugin
Report this message as abusive
Niels Henriksen

User


Joined: Mon Sep 27th 2004
Location: Behind you breathing heavely
Posted: 15th Sep 2007 03:07           | link | toggle

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
Back to top
Netopcom Webhosting Find user on ICQ
Report this message as abusive

Go to the first page of this board Return to the Forum Menu Post Message
23 Messages - Page   of 1   
Search the Forum

Sorry, but it has been so long since anyone replied to this Thread that it has been automatically locked.
You may read it but not reply.

Forum Search

Enter a word or phrase to search our Forum for:

Thread Subject Search
Search Phrase:
Search Scope: Entire forum
Just this board
 
Google Forum Search
Search Phrase:
 
Apollo v2.02


Dark Game Studio
Privacy Policy AUP Top of Page