Example #1
0
    public void OnConnect(EndPoint endPoint)
    {
        Debug.Log("[Server][" + DateTime.Now + "] Receive CONNECT " + endPoint);
        if (!clients.Contains(endPoint))
        {
            clients.Add(endPoint);
            clientGuids[endPoint]      = Guid.NewGuid().ToString();
            lastPingToClient[endPoint] = DateTime.Now;


            //TODO: move this somewhere else, it shouldn't happen here
            toDos.Enqueue(() => {
                GameObject ship = manager.CreateCapitalShip(Guid.NewGuid().ToString(), "CapitalShipOne");
                ship.GetComponent <Ship>().ownerGuid = clientGuids[endPoint];
            });
        }

        CONNECT(endPoint, clientGuids[endPoint]);
    }