Home
Products
Community
Manuals
Contact
Login or Signup

Code archives/Networking/MultiLibV1.2 Final

This code has been declared by its author to be Public Domain code.

Download source code

MultiLibV1.2 Final by AntonyWells(Posted 1+ years ago)
Based on TCP, this is a free/open source event driven network library for blitz+/3d and maybe even b2d.
Takes advantage of gNet internaly to allow you to find servers across the globe.

This has nothing to do with BlitzNet, which is due to be launched again very soon.
Will reupload, when I find it again.

Comments

Beaker(Posted 1+ years ago)
Any simple examples of use?


AntonyWells(Posted 1+ years ago)
Yep, here's a little chat client I did.

Bear in mind I wrote this over a year ago I think..so if anyone has questions..don't be vague..be explicit. ;)


Type player
	Field x,y,z
	Field netId
End Type

initMultiSys()

	d$ =Input("1 = server,2=client>")
	If d=1
		test.server =createServer( "test")
		If test=Null End
		Print "server created, I.P>"+serverIP( test)
	Else If d=2
		cli.client =connectClient(Input("127.0.0.0 = local>"))		
		If cli =Null End
		Print " connected to server"
	EndIf

;Graphics 320,240,0,2
;SetBuffer BackBuffer()


Repeat
	
	If d=1 ;server
		eventCount =srvEventCount( test)
		If eventCount
		For j=1 To eventCount
			Select srvGetEvent( test,j)	
				Case sNewClient 										;sNewClient = lib const. New clinet has logged on.
					player.player = New player       				   ;player type is specific to the this example only.
					player\netId =srvGetEventNetId( test,j)				 ;get the net id of the client just logged on. 
					Print "new client joined."
				Case gNewData ;data has been recieved.
					For player.player =Each player						 	;\let's find the player that has the same net id
						If player\netId = srvGetEventNetId( test,j)        ;as the sender of the data./
							Select srvGetEventChannel( test,j) 				;get the channel id string
								Case "chat"									 ;see clSendString for where 'chat' originates from
									msg$ =srvGetEventString( test,j) 		;get the string.
									Print ">"+msg
									srvBroadCastString( test,msg,"chat") ;route to all other clients.
							End Select
						EndIf
					Next
			End Select
		Next
		EndIf
		If KeyDown(57) srvBroadCastString(test,0,Input(">"),"chat")
		;srvSendString( server, netIdtoSendTo,string) to send to just one client.
	Else ;client
		;clSendString( client, string to send, channel(Optional par) channel can be any text string.(Custom)
		If KeyDown(57) clSendString( cli,Input(">"),"chat") 
		eventCount =clEventCount( cli) ;same syntax as server funs
		If eventCount
		For j=1 To eventCount
			Select clGetEvent( cli,j)
				Case gNewData
					Select clGetEventChannel( cli,j)
						Case "chat"
							Print clGetEventString( cli,j)
					End Select
			End Select
		Next
		EndIf
	EndIf
	netCycle()
Until KeyDown(1)





Ziltch(Posted 1+ years ago)
Very clever work.
Thanks


Craig H. Nisbet(Posted 1+ years ago)
I can't find this lib code. Does it exist anymore?


Code Archives Forum