Esempio n. 1
0
 private NetGame(NetRole role, NetPeerConfiguration config, INetDataMessageHandler handler, Action <NetPeer> connect)
 {
     Role     = role;
     _handler = handler;
     _connect = connect;
     Net      = new NetServer(config);
 }
Esempio n. 2
0
 public static NetGame CreateClient(string appId, string host, int port, INetDataMessageHandler handler)
 {
     return(new NetGame(NetRole.Client, new NetPeerConfiguration(appId), handler, connect: net =>
     {
         net.Start();
         net.Connect(host, port);
         Event.Publish(new Connected(new Connection($"{host}:{port}", port)));
     }));
 }
Esempio n. 3
0
 public static NetGame CreateHost(string appId, int port, INetDataMessageHandler handler)
 {
     return(new NetGame(NetRole.Host, new NetPeerConfiguration(appId)
     {
         Port = port
     }, handler, connect: net =>
     {
         net.Start();
     }));
 }