Exemple #1
0
    void StartServer()
    {
        Debug.Log("Starting server...");

        utils = new NetworkingUtils();
        utils.SetDebugCallback(DebugType.Message, debug);

        status = OnServerStatusUpdate;
        utils.SetStatusCallback(status);

        server = new NetworkingSockets();

        Address address = new Address();

        address.SetAddress("::0", port);

        listenSocket = server.CreateListenSocket(ref address);

        //connectedPollGroup = server.CreatePollGroup();
    }
    public void ConnectToServer(string username, OnConnect onConnect, OnDisconnect onDisconnect, OnReject onReject)
    {
        this.onConnect    = onConnect;
        this.onDisconnect = onDisconnect;
        this.onReject     = onReject;

        utils = new NetworkingUtils();
        utils.SetDebugCallback(DebugType.Message, debug);

        Reset();

        client = new NetworkingSockets();

        Address address = new Address();

        address.SetAddress(serverIP, serverport);

        status = OnClientStatusUpdate;
        utils.SetStatusCallback(status);

        connection = client.Connect(ref address);
    }