示例#1
0
 void CompleteCheckVersion(string version)
 {
     if (version == Application.version)
     {
         AcceptVersion?.Invoke("");
     }
     else
     {
         DeniedVersion?.Invoke(version);
     }
 }
示例#2
0
    void Update()
    {
        NetIncomingMessage message;

        if (client != null)
        {
            if ((message = client.ReadMessage()) != null)
            {
                switch (message.MessageType)
                {
                case NetIncomingMessageType.Data:
                    switch ((GlobalServerTransmissionEnum)message.ReadByte())
                    {    /*
                          * case GlobalServerTransmissionEnum.CheckVersionOnLoad:
                          *     {
                          *         string msg = message.ReadString();
                          *         CompleteCheckVersion(msg);
                          *     }
                          *     break;
                          * case GlobalServerTransmissionEnum.Login:
                          *     {
                          *         bool result = message.ReadBoolean();
                          *         if (result == false)
                          *         {
                          *             LoginDenied?.Invoke();
                          *             break;
                          *         }
                          *         string _data = message.ReadString();
                          *         player = JsonConvert.DeserializeObject<PlayerLocalServer>(_data);
                          *         LoadMainMenu?.Invoke();
                          *     }
                          *     break;
                          * case GlobalServerTransmissionEnum.RequestServerList:
                          *     {
                          *         string name = message.ReadString();
                          *         int port = message.ReadInt32();
                          *         byte playersMax = message.ReadByte();
                          *         byte playersConnected = message.ReadByte();
                          *         string onLoadMessage = message.ReadString();
                          *         string gamemode = message.ReadString();
                          *         string map = message.ReadString();
                          *         ServerList?.Invoke(name, port, playersMax, playersConnected, onLoadMessage, map, gamemode);
                          *     }
                          *     break;
                          * case GlobalServerTransmissionEnum.ResendPlayerInfo:
                          *     {
                          *         string data = message.ReadString();
                          *         player = JsonConvert.DeserializeObject<PlayerLocalServer>(data);
                          *         GetNewData?.Invoke();
                          *         break;
                          *     }
                          * case GlobalServerTransmissionEnum.GetServerData:
                          *     {
                          *         string data = message.ReadString();
                          *         balance = JsonConvert.DeserializeObject<ItemsData>(data);
                          *     }*/
                    }
                    break;

                case NetIncomingMessageType.StatusChanged:
                    switch ((NetConnectionStatus)message.ReadByte())
                    {
                    case NetConnectionStatus.Disconnected:
                    {
                        DeniedVersion?.Invoke("Problems with connection to global server!");
                    }
                    break;
                    }
                    break;
                }
                client.Recycle(message);
            }
        }
    }