Пример #1
0
    public void Init(NetWorker server, ServerConfig config, RPCPackager rpcPackager)
    {
        Instance     = this;
        m_server     = (UDPServer)server;
        Players      = new Dictionary <string, PlayerModel>();
        MaxPlayers   = config.MaxPlayers;
        RPCInterface = new ServerInterface(rpcPackager);

        m_server.playerTimeout += (player, sender) =>
        {
            Debug.Log($"Player: {player.NetworkId} timed out.");
        };

        m_server.playerConnected += (player, sender) =>
        {
            PlayerConnected(player);
        };

        m_server.playerGuidAssigned += (player, sender) =>
        {
            Debug.Log($"Player: {player.NetworkId} assigned GUID: {player.InstanceGuid}");
        };

        m_server.playerAccepted += (player, sender) =>
        {
            MainThreadManager.Run(() => { PlayerAccepted(player); });
        };

        m_server.playerRejected += (player, sender) =>
        {
            Debug.Log($"Player: {player.NetworkId} rejected.");
        };

        m_server.playerDisconnected += (player, sender) =>
        {
            PlayerDisconnected(player);
        };
    }
Пример #2
0
 public ClientInterface(RPCPackager rpcPackager)
 {
     m_RPCPackager = rpcPackager;
 }
Пример #3
0
 public ServerInterface(RPCPackager rpcPackager)
 {
     m_RPCPackager = rpcPackager;
 }