The Game Creators
The Game Creators Home Online Shop Click to Login
  Hot: Christmas CompetitionNovember NewsletterModel Pack 36DB Pro Pack 2009DGS BonanzaCharacter PackFPS Creator Bonanza;
The Game Creators
Program Announcements / EZ_Serv is now FREE! - Multiplayer Server for DBP just went freeware...

Go to the first page of this board Return to the Forum Menu Post Message
78 Messages - Page   of 2   
Bookmark and Share Search the Forum Next 40

Author Message
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 6th Aug 2005 16:12     Edited: 7th Aug 2005 19:12     | link | toggle

yes, free - and introducing the latest version, 1.5

I have decided to release EZ_Serv as a free application. All versions from here on out (1.5 and beyond) are completely free to use and distro as you please. I am hoping to gain feedback and further develop (revamp if necessary) this application to fit all of your multiplayer/multiuser needs.

If you have never heard of, or have never used EZ_Serv:
Please visit http://www.mod2software.com/dbp/dbp.htm where you can link to the EZ_Serv home page, but also, while you're there, take a look at the other free offerings for DBP which include plugins for Databasing and TCPIP communications, as well as links to other peoples works, such as Exeat's Winsock Plugin and Wendigo's EZS-VB6 class.

*Note: Wendigo's VB6 EZS package on my web page needs to be updated to reflect the changes to the ezs protocol. The current version was written around the ezs protocol stubs which contained "qs_" prefixes. These prefixes have been removed, thusly breaking any parser code that expects them - like in the VB6 code. If you decide to download the vb6 package before it has been updated, you will need to change the constants/code before use. Read the section below regarding protocol stubs for more detail.

Current EZ_Serv users, a few things have changed:
First let me say that the core inner workings of ezs have not changed between 1.5 and earlier versions like 1.4, but some naming conventions and the like have changed, including the EZS Protocol. All of the ezs protocol messages now do not include the "QS_" prefix. QS comes from the original app name "QuickServer" which I had to change just after 1.0 was released (my fault). Ever since then I have preserved this "qs_" naming convention throughout the protocol, as well as throughout my code - no more. Every reference to qs_ has been removed, including subdirectory names, file extensions, and protocol stubs. You can install version 1.5 and still maintain your older version's install and integrity by simply installing the newer version in a different directory when prompted. The installer will want to overwrite your "C:program filesez_serv" directory during the install, simply change the ez_serv bit to something else and you can run and examine the differences in both versions on the same pc. Below is a list of the noteable changes effecting end users

- Profile files .qsp files are now .ezsp files
- QSLogfiles subdir is now EZS_Logfiles
- QSProfiles subdir is now EZS_Profiles
- ALL protocol stubs have dropped the "QS_" prefix. Under 1.5 you will need to update your code to look for the same protocol stubs minus the QS_ prefix. Example "QS_PING" messages now arrive as "PING", "QS_CL_EXIT" now arrives as "CL_EXIT" etc etc. Luckily there are not too many protocol messages to change, and a simple FIND/Step replace should due nicely. Sorry to have done this but the QS bit was bugging me. Look on the bright side, we save 3 bytes per message in the bandwidth usage

Well, thats all at the moment. All feedback is welcome and appreciated.

Links
EZ_Serv Home: http://www.mod2software.com/ezs/ez_serv.htm
EZ_Serv Docs: http://www.mod2software.com/EZS/EZ_Serv_UG.htm
My DBP Page: http://www.mod2software.com/dbp/dbp.htm

Back to top
Report this message as abusive
Dot Merix

User


Joined: Wed Oct 15th 2003
Location: Manitoba, Canada
Posted: 6th Aug 2005 17:16           | link | toggle

Wicked



WindowsXP Home(Service pack 2), Athlon XP 2400+(2.1Ghz), 1GIG Ram, Ati Radeon 9800Pro 128MB.
Back to top
Report this message as abusive
Frozen Flame

User


Joined: Thu Jul 22nd 2004
Location: Cyberspace
Posted: 6th Aug 2005 18:36           | link | toggle



Thats very nice CR
Thanks.


School is supposed to be teaching our kids how to read and write. Not about dangerous drugs like PHP.
Back to top
Galekus Send AIM user a message
Report this message as abusive
Oneka

User


Joined: Sat Apr 24th 2004
Location: Hampton,VA
Posted: 6th Aug 2005 20:40           | link | toggle

yay......but noooo I mean yeah x_x;

Making better games everday!
Oh yeah and just so you know its Oh-nek-a not One-ka!
Back to top
Send AIM user a message
Report this message as abusive
Lost in Thought

User


Joined: Wed Feb 4th 2004
Location: U.S.A. : Douglas, Georgia
Posted: 7th Aug 2005 02:11           | link | toggle

Awesome I was going to buy it eventually. Can you put up a donations link in case I ever get the money?

Back to top
Find user on ICQ
Report this message as abusive
Darkbasic MADPSP

User


Joined: Wed Jun 15th 2005
Location: Uk
Posted: 7th Aug 2005 05:20     Edited: 7th Aug 2005 05:23     | link | toggle

looks great but can you use it in dbpro if you want to create net games? e.g something like the halo multiplayer?

life's a game and a games a life More games at www.freewebs.com/halorc
Back to top
It\'s a link click it lol
Report this message as abusive
Mikey P

User


Joined: Mon May 23rd 2005
Location: Manchester, UK
Posted: 7th Aug 2005 10:15           | link | toggle

Heh, Cattle, here's the idea you wanted me to post up:

Like giving the Server the feature to process stuff, like for some games, positions of items dropped by users, or NPCs. It'd be really easy to do, just allow the person to make his own protocol commands, so that when the client sends the command to the server, it executes the person's script [Lua maybe? There's a .NET Lua thing somewhere, LuaScript I think...] and allows the script to keep server/zone-wide variables or something... Not sure if I'm making sense, but it works in my head

Back to top
Send AIM user a message
Report this message as abusive
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 7th Aug 2005 10:49           | link | toggle

Thanks Mikey.
LOL L.I.T.

Quote: "looks great but can you use it in dbpro if you want to create net games? e.g something like the halo multiplayer?"
EZ_Serv is an alternative to using dbp's built in multiplayer stuff. Moggie100 and I are throwing together a multiplayer game as an open source demo for EZS, and a couple of other things.

I will edit the DBP Tutorials and repost them today.

There are a few mplayer games in development using ezs, maybe those guys could post some screenies and some info to give people reading this thread an idea of what ezs is capable of.

DBP Plugins | EZ_Serv 1.5 EZ_Serv is now free! Check it out.
Back to top
Report this message as abusive
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 7th Aug 2005 14:35     Edited: 7th Aug 2005 15:24     | link | toggle

The previous tutorials have been removed from my page. I have found a few problems in the cr_strings.dba, and the ezs.dba files. I have corrected them and made sure all the protocol constants have been updated to the new ezs protocol. If you have downloaded the older tutorials 1 & 2 i would delete them and download the newer single tutorial. The new tutorial starts from old tutorial 2. Old tutorial 1 was pointless anyway I will be posting the new tutorial shortly. Use my sig link to go there.

EDIT: New tutorial project posted

DBP Plugins | EZ_Serv 1.5 EZ_Serv is now free! Check it out.
Back to top
Report this message as abusive
Zero Blitzt

User


Joined: Sun Jan 18th 2004
Location: Different Stages
Posted: 7th Aug 2005 15:38           | link | toggle

If I wasn't in Linux right now, and if I could get WINE to work, I'd make something with it


Who are the brain police?
Back to top
KNova Send AIM user a message
Report this message as abusive
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 7th Aug 2005 16:03           | link | toggle
Back to top
Report this message as abusive
MrTus

User


Joined: Sun Aug 7th 2005
Location: Inside of a TCP/IP Protocal
Posted: 7th Aug 2005 16:55           | link | toggle

Awesome. I'll have to give this a try then ^_^
Back to top
DevHat Send AIM user a message
Report this message as abusive
The admiral

User


Joined: Thu Aug 29th 2002
Location: Cyberspace
Posted: 9th Aug 2005 01:30           | link | toggle

Thats a very generous thing to do thank you very much.

The admiral
Back to top
Flyer Command Home Site Send AIM user a message
Report this message as abusive
jrowe

User


Joined: Sat Oct 12th 2002
Location: Capital of Sophistication.... Redditch
Posted: 9th Aug 2005 04:07     Edited: 9th Aug 2005 06:58     | link | toggle

Thank you CR, big contribution to the community.

For Fathers and Sons who enjoy wholy spirits.
Back to top
Report this message as abusive
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 9th Aug 2005 05:54           | link | toggle

thanks, i'd rather make a good proggie than make a buck form it. hopefully some of you can give it a go and post some suggestions.

Back to top
Report this message as abusive
Darkbasic MADPSP

User


Joined: Wed Jun 15th 2005
Location: Uk
Posted: 9th Aug 2005 11:32           | link | toggle

so do i add this as a seperate exe on dbpro?

See you at the convention!
Back to top
It\'s a link click it lol
Report this message as abusive
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 9th Aug 2005 13:55           | link | toggle

no. EZS doesnt run out of dbp. Its its own server application that you can run locally or on a dedicated machine. Ezs handles all of the server-based stuff for you, so you can concentrate on making a dbp game/client. DBP hogs the system as it is, why anyone would want it to be a server too is beyond me but thats only mho.

Back to top
Report this message as abusive
Dom

User


Joined: Mon May 31st 2004
Location: UK - England (I hate Chavs)
Posted: 9th Aug 2005 15:55           | link | toggle

Nice, I looked at this not too long ago, thought it might be useful but I couldnt pay for it so Im donwloading just incase i ever need to use it Thank you very much CR

"A book. I hate books. book is stupid." -- Some lame idiot
Formerly Saberdude --DFStudios--
Back to top
www.dfstudios.tk
Report this message as abusive
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 10th Aug 2005 19:05           | link | toggle
Back to top
Report this message as abusive
MikeS

Moderator


Joined: Mon Dec 2nd 2002
Location: United States
Posted: 10th Aug 2005 21:05           | link | toggle

This is great news CR! Now I have no excuse not to use this for my multiplayer needs. Will download and give it a go first thing this weekend. This is definitly worth a mention in the newsletter, so talk to rich.



A book? I hate book. Book is stupid.
(Formerly Yellow)
Back to top
Report this message as abusive
Google Ad
Back to top
 
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 11th Aug 2005 06:37           | link | toggle

Thanks mike.

Upcoming additions(no particular order):
-configurable zone MOTD's
-CL_JOIN, CL_EXIT, CL_LIST per zone
-the server persisted lists like Mikey P mentioned above
-ability for server to not convert all mesages to string. this would allow the passing of any data thru the server including things like memblocks and files.

post suggestions here

Back to top
Report this message as abusive
Dot Merix

User


Joined: Wed Oct 15th 2003
Location: Manitoba, Canada
Posted: 12th Aug 2005 16:01           | link | toggle

This should be stickied i think.



WindowsXP Home(Service pack 2), Athlon XP 2400+(2.1Ghz), 1GIG Ram, Ati Radeon 9800Pro 128MB.
Back to top
Report this message as abusive
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 12th Aug 2005 21:13           | link | toggle

thanks
I cant sticky my own thread, morally.

If some other mod sees fit, they will

Back to top
Report this message as abusive
Ace Of Spades

User


Joined: Sun Mar 6th 2005
Location: Across the ocean
Posted: 13th Aug 2005 00:14           | link | toggle

Will this always be free now, 100%? Or should I grab it now and hope not to lose it?

Back to top
50% Off All Products! Find user on ICQ Send AIM user a message
Report this message as abusive
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 13th Aug 2005 12:28           | link | toggle

always free - 100%

Back to top
Report this message as abusive
SageTech

User


Joined: Fri Dec 3rd 2004
Location: Orlando, Florida
Posted: 13th Aug 2005 19:37           | link | toggle

Woohoo, me loves this, had an eye out for it for a while ago but just didnt have money, but now its free, thanks, this will be quite usefull for my new project(Not mayor, as you rember it went bad and not another 1337 MMORPG). Thanks a bunch.

If you're so smart, why are you reading my post?
Back to top
BattleLegacy Send AIM user a message
Report this message as abusive
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 13th Aug 2005 23:02           | link | toggle
Back to top
Report this message as abusive
Jess T

Moderator


Joined: Sat Sep 20th 2003
Location: Over There... Kablam!
Posted: 13th Aug 2005 23:35           | link | toggle

Nice work, CR

Shall be a great contribution to the community - Thanks.

Team EOD :: All-Round Nice Guy
Want Better dbHelp Files?
Back to top
jt0.org
Report this message as abusive
Darkbasic MADPSP

User


Joined: Wed Jun 15th 2005
Location: Uk
Posted: 16th Aug 2005 06:33           | link | toggle

I'm confused now
How if i wanted to use this in my own games like gtracer would i use this because it might go public one day or would i have to use dbpros built in stuff?

Love games go to http://www.freewebs.com/halorc
or
http://www.freewebs.com/gamersmad
Back to top
It\'s a link click it lol
Report this message as abusive
Dot Merix

User


Joined: Wed Oct 15th 2003
Location: Manitoba, Canada
Posted: 17th Aug 2005 12:28           | link | toggle

...What? Specify more clearly what the problem is or question is.



WindowsXP Home(Service pack 2), Athlon XP 2400+(2.1Ghz), 1GIG Ram, Ati Radeon 9800Pro 128MB.
Back to top
Report this message as abusive
Alkaline

User


Joined: Thu Dec 4th 2003
Location: Seattle, Washington
Posted: 18th Aug 2005 03:53           | link | toggle

umm im totally confused on how this works or how to use this...even when i try to run the dbpro examples i get and error on ever one. For an example when i try to run ezs.dba i get an error at line 38 which is ws_connect Host, port.???? please help me understand this

768 DDR pc3200||ATI 9600xt 256mb||330 GB hard drive||Amd XP 3000+
InDex v2.0http://forum.thegamecreators.com/?m=forum_view&t=58885&b=8
Back to top
Send AIM user a message
Report this message as abusive
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 18th Aug 2005 07:53     Edited: 18th Aug 2005 07:54     | link | toggle

some people have said the dbp example wont compile, etc. First make sure DBP is 5.8 and that you have ALSO downloaded Exeat's winsock plugin from my page. There are 2 there, the older is the one I used for this demo. People have reported bugs with the newer one, but both should work. Put the winsock plugin in your plugins-user directory under your DBP install folders.

Aside form that youll need EZS 1.5 (free download) and the .NET framework 1.1 on the machine that will run the EZS app.

Once all that is in place I can help you with dbp coding for ezs multiplayer.

Back to top
Report this message as abusive
Dot Merix

User


Joined: Wed Oct 15th 2003
Location: Manitoba, Canada
Posted: 18th Aug 2005 15:21           | link | toggle

I'm having some problems aswell actually..

I downloaded Exeats winsock plugin and it's in my plugin directory for darkbasic.. Just in case, i also tried it inside the same directory as the darkbasic project file..

The error i'm receiving is "Cannot perform 'string' cast on type 'FS@cr_Split@_' at line 205



WindowsXP Home(Service pack 2), Athlon XP 2400+(2.1Ghz), 1GIG Ram, Ati Radeon 9800Pro 128MB.
Back to top
Report this message as abusive
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 18th Aug 2005 19:43           | link | toggle

post the code that causes the error.

there may be another bug in my split func, but I have tested with many conditions and its ok here. You dont need to use that splitter or any of the tutorial code really, you could write or use whatever to get the job done - my stuff is an example really but aside from that it should be working...

Back to top
Report this message as abusive
Dot Merix

User


Joined: Wed Oct 15th 2003
Location: Manitoba, Canada
Posted: 18th Aug 2005 22:09           | link | toggle

I dont suppose you could throw a small tutorial... or maybe just a project file together that explains how to connect and handle multiple connections to EZ_Serv and distribution of data to each client connected in a project as simple as possible...

Maybe just a simple chat client that can connect and talk to others connected to the EZ_Serv program.



WindowsXP Home(Service pack 2), Athlon XP 2400+(2.1Ghz), 1GIG Ram, Ati Radeon 9800Pro 128MB.
Back to top
Report this message as abusive
Darkbasic MADPSP

User


Joined: Wed Jun 15th 2005
Location: Uk
Posted: 19th Aug 2005 03:07           | link | toggle

he asked you to post the code what i meant is this copyright protected d do i install a seprate exe into my game?

Love games go to http://www.freewebs.com/halorc
or
http://www.freewebs.com/gamersmad
Back to top
It\'s a link click it lol
Report this message as abusive
Dot Merix

User


Joined: Wed Oct 15th 2003
Location: Manitoba, Canada
Posted: 19th Aug 2005 13:41     Edited: 19th Aug 2005 13:42     | link | toggle

I know what he asked me.

EZ_Serv is a standalone application.. You'll have to set a computer up as the server, and run EZ_Serv on that computer and get all of your clients(You'll have to make the clients) to connect to it.



WindowsXP Home(Service pack 2), Athlon XP 2400+(2.1Ghz), 1GIG Ram, Ati Radeon 9800Pro 128MB.
Back to top
Report this message as abusive
CattleRustler

Moderator


Joined: Fri Aug 8th 2003
Location: case modding at overclock.net
Posted: 19th Aug 2005 14:54           | link | toggle

Right but theres no problem running EZS on a pc and having a client running on that same pc. DBMad, theres no restriction on the EZS app so you can share it or whatever but remember, if youre coding a client you only need one server running somewhere, not a copy of ezs distributed with each copy of the client.

Merix I'll see what I can do - are you using the latest tut thats up there? That tutorial is not far from being a simple chat app as it is. Just needs to display user list and text messages, and provide a message entry routine.

Back to top
Report this message as abusive
Darkbasic MADPSP

User


Joined: Wed Jun 15th 2005
Location: Uk
Posted: 19th Aug 2005 14:57           | link | toggle

thanks would it be okay then if i made a game and put ez serv on each disk so that the multiplayer will work all the time?

Love games go to http://www.freewebs.com/halorc
or
http://www.freewebs.com/gamersmad
Back to top
It\'s a link click it lol
Report this message as abusive
Dot Merix

User


Joined: Wed Oct 15th 2003
Location: Manitoba, Canada
Posted: 19th Aug 2005 17:43     Edited: 19th Aug 2005 17:43     | link | toggle

I was indeed using the latest tutorial..

EZS_Comms
+ Code Snippet
REM Project: EZS_Comms
REM Created: 2/17/2005 15:43:22
REM
REM ***** Code by CattleRustler *****
REM ***** The Definitive EZ_Serv Tutorial for DBP *****
REM ***** Requires Exeat's Winsock Plugin for DBP *****
REM ***** Visit http://www.mod2software.com/dbp/dbp.htm for ezs demo and winsock plugin *****

`Uses the included files ezs.dba & cr_strings.dba to demonstrate how to
`incorporate EZ_Serv into a DBP program
`http://www.mod2software.com/ezs/ez_serv.htm for more info


`set up our font
set text font "Arial"
set text size 14

`you need to dim this dynamic array in this program, or any program
`that uses cr_strings.dba
dim cr_SplitData() as string

`a temp string to retrieve each new server message
sTemp as string


`TUT 2: Set up a type array to hold info about all of the clients
`on the server, including the former ME session
Type AllClientsOnServer
    nick as string
    id as string
    password as string
    guid as string
EndType

`TUT 2: Define the array with 1 element - our client will always occupy this
`element at index 0
Dim Client(0) as AllClientsOnServer
Client(0).nick = "a"
Client(0).password = "a"


`connect to EZ_Serv
`Host can also be an IP address, a machine name, or a url
`in this case EZS is running locally so we use "localhost"
ezs_connect("localhost",9999)


DO
    sTemp=""

    `check message buffer for incoming messages
    sTemp=ezs_receive()

    `if we have a message from server send it to our parser
    if sTemp <> ""

        `echo the raw data to the screen
        print "RAW ECHO: " + sTemp :`+ "(" + str$(len(sTemp)) + ")"

        ezs_Parser(sTemp)
    endif

    `initiate a disconnect from the server when ctrl key is pressed
    if controlkey()=1
        `DebugLog() :`requires DBP_NETLIB 1.4.3
        `I used this for local debugging while writing this tutorial
        `it is not necessary for you to have dbp_netlib for this EZS tutorial

        ezs_Disconnect()
        end
    endif
LOOP
end

`Used for local debugging of this tutorial
remstart
function DebugLog
    iLoop as integer
    iUB as integer
    iUB=array count(client())

    for iloop=0 to iUB
        fil_appendfile "debuglog.txt", str$(iloop)
        fil_appendfile "debuglog.txt", client(iloop).nick
        fil_appendfile "debuglog.txt", client(iloop).id
        fil_appendfile "debuglog.txt", client(iloop).guid
        fil_appendfile "debuglog.txt", "---------------------------------"
    next iLoop

endfunction
remend



EZS
+ Code Snippet
REM *** Include File: EZS.dba ***
REM Created: 2/17/2005 15:45:17
REM Programmer: CattleRustler
REM Updated: 8/7/2005

`CONSTANTS **************************************************
`GENERAL
#Constant cTERM             = chr$(13)+chr$(10)
#Constant cFALSE            = 0
#Constant cTRUE             = 1
#Constant cC                = ","
#Constant cS                = " "

`PROTOCOL STUBS INBOUND FROM SERVER (client needs to handle these)
#Constant cEZS_CONNID        = "CONNID"
#Constant cEZS_REQLOGIN      = "REQLOGIN"
#Constant cEZS_DUPLOGIN      = "DUPLOGIN"
#Constant cEZS_LOGIN_OK      = "LOGIN_OK"
#Constant cEZS_LOGIN_FAIL    = "LOGIN_FAIL"
#Constant cEZS_LOGIN_PENDING = "LOGIN_PENDING"
#Constant cEZS_PING          = "PING"
#Constant cEZS_DISCONN       = "DISCONN"
#Constant cEZS_CL_LIST       = "CL_LIST"
#Constant cEZS_CL_JOIN       = "CL_JOIN"
#Constant cEZS_CL_EXIT       = "CL_EXIT"
#Constant cEZS_TIME          = "TIME"
#Constant cEZS_REQCLIVER     = "REQCLIVER"

`PROTOCOL STUBS OUTBOUND FROM CLIENT (expected by EZS)
#Constant cEZS_PONG          = "PONG"
#Constant cEZS_LOGIN         = "LOGIN"
#Constant cEZS_REQTIME       = "REQTIME"
#Constant cEZS_CLIVER        = "CLIVER"
`************************************************************

function ezs_Connect(Host as string, Port as Integer)
    `//attempts to connect to server
    ws_connect Host, port
    wait 100
endfunction

Function ezs_Send(Prot as string, Enum as string, ID as string, rID as string, sData as string)
    `concatenates and sends a valid message to the server
    `the server ALWAYS expects a 5-bucket comma delimited message
    `eg: prot,enum,ID,remoteID,any Data + sockets termination cTERM
    `below we concat a string to fit this format
    ws_send prot+cC+enum+cC+id+cC+rID+cC+sData+cTERM
endfunction

function ezs_Receive()
    `checks for server messages in the winsock receive buffer
    `if a messages is found it is returned
    sData as string
    if ws_messagecount() > 0
        sData=ws_receive()
    endif
endfunction sData

function ezs_Disconnect()
    `cleanly disconnects from server by issuing socket close
    ws_close
endfunction

function ezs_Parser(sData as string)
    `TUT 2:
    `incoming EZS messages are always comma delimited so we can use cr_Split
    `to populate a dynamic array. The array is made up of each comma-delimited
    `piece of the entire single message. Each time this function is called
    `the array is cleared and repopulated with the new message data. Using
    `this technique allows easy inspection of the message parts, and also allows
    `us to not care about how many comma-delimited parts are in the message

    `empty the array of old data from last message, if any
    empty array cr_SplitData()

    `ALWAYS trim off any unwanted chars from the end of the message
    `(eg: chr$(13)+chr$(10)) - Sockets uses chars like these as termination
    `characters. If we carry them over in the split, it will cause problems
    `for us later, so lets get rid of any that we find.
    `Calling the same code twice will account for possible inverted cr-lf
    `feel free to use a more elegant way but I would recommend NOT just
    `lopping off the last two characters of the message
    if right$(sData,1)=chr$(10) or right$(sData,1)=chr$(13)
        sData=cr_mid(sData,1,len(sData)-1)
    endif
    if right$(sData,1)=chr$(10) or right$(sData,1)=chr$(13)
        sData=cr_mid(sData,1,len(sData)-1)
    endif

    `populate array with constiuent parts of the new message
    `the message is sData, cC is our constant for comma ","
    cr_Split(sData,cC)

    `The Protocol stub is always in bucket Zero in the array - it doesnt
    `matter if it is an EZS Prot stub or your own prot stub via PPT.

    `CONDITIONS OF BUCKET ZERO (Protocol Stub)
    `EZS Constants


    `TUT 2: successful connection
    if cr_SplitData(0)=cEZS_CONNID
        `set our client(0) with the connection id's
        `store this data how you like but you must store it for later
        Client(0).guid=cr_SplitData(1)
        Client(0).id=cr_SplitData(2)
    endif

    `TUT 2: login request
    if cr_SplitData(0)=cEZS_REQLOGIN
        `when a login request is received our next data sent must be valid
        `login data, or we will get disconnected by the server
        ezs_Send(cEZS_LOGIN,"3",Client(0).id,"",Client(0).nick + "*" + Client(0).password)
    endif

    `TUT 2: ping received
    if cr_SplitData(0)=cEZS_PING
        `when a ping is received we must reply with a pong or be
        `disconnected from EZS - no time like the present...
        ezs_Send(cEZS_PONG,"3",Client(0).id,"","")
    endif

    `TUT 2: Client List Received
    `EZS provides us with a list of connected clients when we first join
    `the server. You can parse and store this list in an array. See
    `SetClientList() and ClearOtherClient() functions for more info
    if cr_splitdata(0)=cEZS_CL_LIST
        SetClientList()
        `debug print
        `print "Indexes: " + str$(array count(client()))
    endif

    `TUT 2: remote client JOIN
    `When another client Joins the server we are notified with a CL_JOIN
    `message. We can use this message to maintain our client array
    if cr_Splitdata(0)=cEZS_CL_JOIN
        `first check if client already exists. Since EZS maintains unique
        `nicks only, we can use the joining nick located in bucket 1
        iTemp as integer
        iTemp=FindClientByServerNick(cr_splitdata(1))

        `when not found (iTemp=-1) add the client to our client array
        if iTemp=-1
            array insert at bottom client()
            client(array count(client())).nick = cr_splitdata(1)
            client(array count(client())).id = cr_splitdata(2)
        endif

        `debug print
        `print "Client Joined - " + client(array count(client())).nick + cc + client(array count(client())).id
        `print "Indexes: " + str$(array count(client()))
    endif


    `TUT 2: remote client EXIT
    `When another client Exits the server we are notified with a CL_EXIT
    `message. We can use this message to maintain our client array
    if cr_Splitdata(0)=cEZS_CL_EXIT
        `find the index in our client array of the exiting client
        iIndex as integer
        iTemp=FindClientByServerNick(cr_splitdata(1))

        `only attempt to remove the client if it exists in our array
        `iTemp holds the index of the client in question
        if iTemp <> -1
            array delete element client(),iTemp
        endif
        `debug print
        `print "Client Exited: " + cr_splitdata(1) + cc + cr_splitdata(2)
        `print "Reason: " + cr_splitdata(3)
        `print "Indexes: " + str$(array count(client()))
    endif

    `TUT 2: Client Version Request
    `EZ_Serv can be set to request client version data from clients as they connect
    `This version data is set at the server and can be anything you like. When the
    `server requests this data, the client must send it back immediately or be
    `disconnected.
    if cr_splitdata(0)=cEZS_REQCLIVER
        `call send method with "TEST_CV" as the client version data
        ezs_Send(cEZS_CLIVER,"3",client(0).id,"","TEST_CV")
    endif

    `TUT 2:
    `The following events are fairly generic and can be dealt with as you like
    `from within your specific client code. Note: the main do loop in this
    `sample code will show some of these as you do your testing. They are not
    `being displayed from here but rather as a result of displaying all raw data
    `we are receiving from the server (see do-loop code)
    `See the EZS documentation for the format of these messages
    if cr_splitdata(0)=cEZS_DUPLOGIN
        `your client attemted to login with nick*pass that is already in use
    endif

    if cr_splitdata(0)=cEZS_LOGIN_OK
        `the login was successful
    endif

    if cr_splitdata(0)=cEZS_LOGIN_FAIL
        `the login attempt failed
    endif

    if cr_splitdata(0)=cEZS_LOGIN_PENDING
        `this client attempted to login with credentials that do not exist
        `on the server. The server has queued these credentials for the server
        `operator. If the server op approves the credentials, the login will
        `succeed on next attempt
    endif

    if cr_splitdata(0)=cEZS_DISCONN
        `the server has disconnected this client!
        `reason is provided in bucket 1 of the message array

        `debug print
        `print "You were disconnected!"
        `print "Reason: " + cr_splitdata(1)

        `there are currently some instances where no reason is given
        `this will be addressed in the next versions of ezs :)
    endif

    if cr_splitdata(0)=cEZS_TIME
        `this message contains the constituent parts of the server date
        `and time. This message can be requested from the server by your client
        `as well as being set on an interval in the SSE objects gui. Below is
        `one way of using the time data...
        `(arrives as time,day,month,year,hour,minute,second)

        `debug print
        print "Server Date: " + cr_splitdata(1) + "/" + cr_splitdata(2) + "/" + cr_splitdata(3)
        print "Server Time: " + cr_splitdata(4) + ":" + cr_splitdata(5) + ":" + cr_splitdata(6)
    endif

    `******************************************************************
    `your custom protocol and condition tests can go here...





endfunction




function FindClientByServerID(ID as string)
    `looks thru client array for server assigned shortID. If it exists
    `its array index position is returned, if not -1 is returned
    iRet as integer
    iRet = -1
    iLoop as integer

    For iLoop=0 to array count(client())
        if client(iLoop).id = ID
            iRet=iLoop
            exitfunction
        endif
    Next iLoop
endfunction iRet


function FindClientByServerNick(Nick as string)
    `looks thru client array for client nick. If it exists
    `its array index position is returned, if not -1 is returned
    iRet as integer
    iRet = -1
    iLoop as integer

    For iLoop=0 to array count(client())
        if client(iLoop).nick = nick
            iRet=iLoop
            exitfunction
        endif
    Next iLoop
endfunction iRet




function SetClientList()
        `insure no clients exist in the array except for our client at 0
        ClearOtherClients()

        iLoop as integer
        iUB as integer
        iUB=array count(cr_splitdata())
        iTemp as integer

        `the first nick in the message array is in index 1 after the split is done.
        `when we joined we received this message:
        `CL_LIST,nick1,id1,nick2,id2,nick3,id3.....
        `for all clients on server


        for iLoop=1 to iUB step 2
            `dont add our client again, it was added manually at app start
            if cr_splitdata(iloop) <> client(0).nick
                array insert at bottom Client()
                iTemp=array count(client())
                client(iTemp).nick = cr_splitdata(iloop)
                client(iTemp).id = cr_splitdata(iloop+1)
            endif

            `debug print
            `print Client(iTemp).nick + cC + Client(iTemp).id
        next iLoop
endfunction


function ClearOtherClients()
    `dumps all clients in our array EXCEPT for our client
    iLoop as integer
    iUB as integer

    `get the upperbound of the array so we know how many indexes to point at
    `for removal from the array. We remove them backwards in the loop

    iUB=array count(client())

    for iLoop=iUB to 1 step -1
        array delete element Client(),iLoop
    next iLoop
endfunction


cr_strings
+ Code Snippet
Rem *** Include File: cr_strings.dba ***
Rem Created: 9/25/2004 10:52:59
Rem Programmer: CattleRustler

`All functions here are meant to as closely resemble the VB functions of
`the same name as possible


`MID
`Returns a substring from a string. If the start value is less than
`1, then 1 is assumed. If the values for start and length cause the
`operation to exceed the length of the original string, the entire
`string is returned. If the length argument is <=0 the entire string
`is returned.
function cr_Mid(str as string, start as integer, length as integer)
    local sTemp as string
    local iLoop as integer
    length=length-1

    `check start
    if start < 1 then start=1

    `check len
    if (length > len(str)-start) or length < 0
        length=len(str)-start
    endif

    `extract substring
    for iLoop=start to start + length
        stemp=stemp + mid$(str,iloop)
    next iLoop
endfunction sTemp
`-----------------------------------------------------------------------


`INSTR
`Retruns an Integer representing the character position of the SearchFor
`string's first occurrence in the searchIn string
function cr_Instr(SearchIn as string, SearchFor as string)
    local iRet as integer = 0
    local iLoop as integer
    local iSILen as integer
    local iSFLen as integer
    local iUpper as integer

    iSILen=len(SearchIn)
    iSFLen=len(SearchFor)

    if iSILen=0 or iSFLen=0 then exitfunction iRet
    if iSFLen > iSILen then exitfunction iRet

    iUpper=(iSILen-iSFLen) + 1

    for iLoop=1 to iUpper
        if cr_mid(searchin,iLoop,iSFLen)=SearchFor
            iRet=iLoop
            exitfunction iRet
        endif
    next iLoop
endfunction iRet
`-----------------------------------------------------------------------


`SPLIT
`Populates an array with the contents of a string that is broken into
`constituent parts based on a delimiter string (arg: delim)
function cr_Split(str as string, delim as string)
    if len(delim) <> 1 then exitfunction

    `if the string is passed in has no delimiter char in it
    `return the entire string in array element 0 and exit
    if cr_instr(str,delim)=0
        array insert at bottom cr_splitdata()
        cr_SplitData(0)=str
        exitfunction
    endif

    `//WHEN DELIMITER EXISTS...
    dim StartPos(0) as integer
    dim DelimPos() as integer

    `static startpos at index 0
    StartPos(0)=1

    local iLoop as integer
    local iArrLoop as integer

    for iLoop=1 to len(str)
        if mid$(str,iLoop)=delim
            array insert at bottom DelimPos()
            DelimPos(array count(DelimPos()))=iLoop

            array insert at bottom StartPos()
            StartPos(array count(StartPos()))=DelimPos(array count(DelimPos()))+1
        endif
    next iLoop

    `add static endpoint delimiter at string end pos + 1
    array insert at bottom DelimPos()
    DelimPos(array count(DelimPos()))=len(str)+1

    `if there were any delimitations besides static at 0
    if array count(DelimPos()) > 0
        for iArrLoop=0 to array count(DelimPos())

            `debug print
            `print "START: " + str$(StartPos(iArrLoop))
            `print "DELIM: " + str$(DelimPos(iArrLoop))


            `add a splitdata holder
            array insert at bottom cr_SplitData()
            `push data into new holder
            cr_SplitData(array count(cr_SplitData())) = _
                         cr_Mid(str,StartPos(iArrLoop),_
                         DelimPos(iArrLoop)-StartPos(iArrLoop))


            `debug print
            `print ">" + cr_SplitData(iArrLoop) + "<INDEX:" + str$(iArrLoop)

        next iArrLoop
    endif

    `dump locally-used arrays
    empty array DelimPos()
    empty array StartPos()
endfunction







WindowsXP Home(Service pack 2), Athlon XP 2400+(2.1Ghz), 1GIG Ram, Ati Radeon 9800Pro 128MB.
Back to top
Report this message as abusive

Go to the first page of this board Return to the Forum Menu Post Message
78 Messages - Page   of 2   
Search the Forum Next 40

This is a multi-page thread older than 30 days.
Go to the last page to check if you can reply to it.

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