private static TcpClientHandler event_clientCreated(SocketBinder binder, TcpServerHandler server, uint clientTimeout) { TcpClientHandler tmp_ = new TcpClientHandler(binder, server, clientTimeout); mainProgram.WriteLine("Client " + tmp_.Socket.ToString() + " has been created"); return(tmp_); }
public static void Main() { //make the socketbinder SocketBinder binder = new SocketBinder(); //make the console queue ConsoleQueue = new Queue <string>(); InitConsoleFile(); //make the settings settings = new SettingsSystem(); //we need to load from the file, if there is one settings.ReadFile(); //lets make the server too game_server = new TcpServerHandler(binder, settings.port, settings.maxConnections, settings.alignment, settings.timeout, settings.address); //start the server game_server.Start(); //now lets set the methods for event stuff game_server.StartedEvent += event_started; game_server.ClientCreatedEvent += event_clientCreated; game_server.ClosedEvent += event_closed; game_server.ReceivedEvent += event_received; game_server.ConnectedEvent += event_connected; game_server.DisconnectedEvent += event_disconnected; game_server.AttemptReconnectEvent += event_attemptReconnect; game_server.ClientOverflowEvent += event_clientOverflow; //now for the game world gameWorld = new GameWorld(game_server); //and now for the main game loop int sleepJump = 0, times = 0; gameSteps = 0; //anything after here is not accessible until the server ends while (game_server.Status) { //commands CommandSystem.DoCommand(CommandSystem.Update()); if (sleepJump == 2) { sleepJump = 0; event_step(); times++; Thread.Sleep(16); } else { sleepJump++; event_step(); times++; Thread.Sleep(17); } sleepJump++; }//whatever after the loop is triggered here when the server is closed UpdateConsoleFile(); Thread.Sleep(1000); }
/// <summary> /// Binds this container to a new socket if it is NOT already bound. /// </summary> /// <param name="binder"></param> public void Bind(SocketBinder binder) { if (Binder != null && Socket >= 0) { return; } Binder = binder; Socket = Binder.Bind(); }
/// <summary> /// Binds this container to a new socket if it is NOT already bound. /// </summary> /// <param name="binder"></param> public void Bind( SocketBinder binder ) { if ( Binder != null && Socket >= 0 ) return; Binder = binder; Socket = Binder.Bind(); }
/// <summary> /// Instantiates an instance of the SocketContainer class usign the specified SocketBinder. /// </summary> /// <param name="binder"></param> public SocketContainer( SocketBinder binder ) { Binder = binder; Socket = Binder.Bind(); }
/// <summary> /// Instantiates an instance of the SocketContainer class usign the specified SocketBinder. /// </summary> /// <param name="binder"></param> public SocketContainer(SocketBinder binder) { Binder = binder; Socket = Binder.Bind(); }