コード例 #1
0
ファイル: Server.cs プロジェクト: KyleMassacre/PlanetServer
	/// <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);
	}
コード例 #2
0
ファイル: Server.cs プロジェクト: KyleMassacre/PlanetServer
	void OnApplicationQuit()
	{
		if (_server != null)
		{
			// remove event handlers
			_server.EventDispatcher.ConnectionLostEvent -= OnConnectionLost;
			_server.EventDispatcher.ExtensionEvent -= OnResponse;
			_server.EventDispatcher.PublicMessageEvent -= OnPublicMessage;

			// tell the server to disconnect this user so it isn't hanging around
			_server.Disconnect();
			_server = null;
		}
	}
コード例 #3
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);
        }
    }
コード例 #4
0
 public ServerThread(PlanetServer server)
 {
     _server = server;
 }