StartAsHost() public method

public StartAsHost ( string name, Action response ) : void
name string
response Action
return void
コード例 #1
0
    public void HostGame(Action <ResponseType> response)
    {
        // Set this player as the host
        Host    = Game.Name;
        Hosting = true;
        DisconnectedWithError = false;

        // Initialize avatar manager and set the host's avatar
        avatars = new AvatarsManager();
        avatars.AddPlayer(Host);
        Game.Manager.AddHost(avatars[Host]);

        net.StartAsHost(Game.Name, (ResponseType res) => {
            if (res == ResponseType.Success)
            {
                net.clientsUpdated         = OnUpdateClients;
                net.onDisconnected         = OnDisconnect;
                net.onUpdateDroppedClients = OnUpdateDropped;
            }
            else
            {
                OnDisconnect();
            }

            response(res);
        });
    }