Esempio n. 1
0
    /// <summary>
    /// Connect the server with the specified IP and port.
    /// </summary>
    /// <param name="ip">IP of host server.</param>
    /// <param name="port">Port of host server.</param>
    public void Connect(string ip, int port)
    {
        _server = new PlanetServer();

        // add handlers for basic actions
        _server.EventDispatcher.ConnectionEvent     += OnConnection;
        _server.EventDispatcher.ConnectionLostEvent += OnConnectionLost;
        _server.EventDispatcher.PublicMessageEvent  += OnPublicMessage;

        _server.Connect(ip, port);
    }
Esempio n. 2
0
    public ServerTest()
    {
        _server = new PlanetServer();

        _server.EventDispatcher.ConnectionEvent     += OnConnection;
        _server.EventDispatcher.ConnectionLostEvent += OnConnectionLost;
        _server.EventDispatcher.LoginEvent          += OnLogin;
        _server.EventDispatcher.ExtensionEvent      += OnResponse;

        _server.Connect("127.0.0.1", 8000);

        ServerThread worker = new ServerThread(_server);
        Thread       thread = new Thread(worker.Update);

        while (!thread.IsAlive)
        {
            worker.Update();

            Thread.Sleep(1);
        }
    }