LiteNetLib icon indicating copy to clipboard operation
LiteNetLib copied to clipboard

S2S Communication

Open Kaladrius2trip opened this issue 9 years ago • 8 comments

There is no way to create a connection between the servers. Alternatively, i can use a separate client on the server side, but it would mean the allocation of the new open port. Do you think this is a good solution ? NetClient сontains a realization of P2P why not do the same for NetServer ?

Kaladrius2trip avatar Jan 10 '17 07:01 Kaladrius2trip

Connection between servers is very rare task. But if you need this feature i will think about it :). Maybe i will merge NetClient and NetServer in one class.

RevenantX avatar Jan 10 '17 10:01 RevenantX

@RevenantX I think this is worth considering. Implement at peer to peer. You have a very similar framework on lidgren. There NetPeer implements all the communication as one-to-many. But I liked most of your implementation.

Kaladrius2trip avatar Jan 10 '17 12:01 Kaladrius2trip

Don't know if it is related but, in my game, i will need to send and receiva data via udp, so client and server must use something like:

        server = new NetServer(this, 100, connectionKey);
        server.DiscoveryEnabled = true;
        server.DisconnectTimeout = 5 * 60 * 1000;
        server.Start(port);

?

Or there is another way? when i put my server to a cloud hosting (like amazon ec2), would it connect successful to a client in a personal computer too?

jradesenv avatar Jan 24 '17 23:01 jradesenv

Don't know if it is related but, in my game, i will need to send and receive data via udp

I don't fully understand what you mean. This library uses UDP (with reliable protocol over it) for communication.

when i put my server to a cloud hosting (like amazon ec2), would it connect successful to a client in a personal computer too?

Clients must connect to server - because they can be behind the NAT

server.DisconnectTimeout = 5 * 60 * 1000;

don't use such big timeout. Library automaticaly sends KeepAlive packets. Keep timeout in range 5 - 10 seconds ( 5000 - 10000 msec )

RevenantX avatar Jan 25 '17 05:01 RevenantX

yes, my client connect to server, but how can my server send message to my clients too? Say my client1 sends movement message with x & y to server. How i make the server send those positions to the other clients? Right now, i started the client too as a server, so i can message between them, but i guess thats not correct

jradesenv avatar Jan 27 '17 23:01 jradesenv

@jradesenv look at unity3d example. It very simple. Server can send messages to any client and to all clients. You can get all connected clients on server by calling server.GetPeers(). And then use peer.SendMessage(...)

RevenantX avatar Jan 28 '17 10:01 RevenantX

Nice haha easy as replace NetServer by NetClient on my client hehe thanks!!!

jradesenv avatar Jan 28 '17 13:01 jradesenv

Done (https://github.com/RevenantX/LiteNetLib/commit/9c3da93c14b3cd2b80dfdcd6fd945e389da1500e and next 5 commits)

RevenantX avatar Feb 06 '17 12:02 RevenantX