Ejemplo n.º 1
0
        static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *__ret = ILIntepreter.Minus(__esp, 0);

            var result_of_this_method = new UnityEngine.HostData();

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
Ejemplo n.º 2
0
        private void Update()
        {
            if (null != this.socket && this.socket.Connected)
            {
                if (0 < this.socket.Available)
                {
                    byte action = (byte)this.socketStream.ReadByte();

                    switch (action)
                    {
                    case ACTION_HOST_REGISTERED:
                        // token
                        byte[] tokenBytes = new byte[16];
                        this.socketStream.Read(tokenBytes, 0, tokenBytes.Length);

                        // hostId
                        byte   hostIdLength = (byte)this.socketStream.ReadByte();
                        byte[] hostIdBytes  = new byte[hostIdLength];
                        this.socketStream.Read(hostIdBytes, 0, hostIdLength);

                        this.token  = System.Text.Encoding.ASCII.GetString(tokenBytes);
                        this.hostId = System.Text.Encoding.ASCII.GetString(hostIdBytes);

                        this.hostRegistered = true;
                        StartCoroutine("UpdateHostData");

                        UnityEngine.Debug.Log("Host registered on master server. (hostId: " + this.hostId + ")");
                        break;

                    case ACTION_HOSTS:
                        // host count
                        byte hostCount = (byte)this.socketStream.ReadByte();

                        UnityEngine.Debug.Log("Hosts: " + hostCount);

                        for (int i = 0; i < hostCount; i++)
                        {
                            // address
                            byte   addressLength = (byte)this.socketStream.ReadByte();
                            byte[] adressBytes   = new byte[addressLength];
                            this.socketStream.Read(adressBytes, 0, addressLength);

                            // port
                            byte   portLength = (byte)this.socketStream.ReadByte();
                            byte[] portBytes  = new byte[portLength];
                            this.socketStream.Read(portBytes, 0, portLength);

                            // name
                            byte   nameLength = (byte)this.socketStream.ReadByte();
                            byte[] nameBytes  = new byte[nameLength];
                            this.socketStream.Read(nameBytes, 0, nameLength);

                            // passwordRequired
                            byte passwordRequired = (byte)this.socketStream.ReadByte();

                            // playerCount
                            byte playerCount = (byte)this.socketStream.ReadByte();

                            // playerLimit
                            byte playerLimit = (byte)this.socketStream.ReadByte();

                            // useNat
                            byte useNat = (byte)this.socketStream.ReadByte();

                            // playerGUID
                            byte   playerGUIDLength = (byte)this.socketStream.ReadByte();
                            byte[] playerGUIDBytes  = new byte[playerGUIDLength];
                            this.socketStream.Read(playerGUIDBytes, 0, playerGUIDLength);

                            UnityEngine.HostData hostData = new UnityEngine.HostData();
                            hostData.ip                = new string[1];
                            hostData.ip[0]             = System.Text.ASCIIEncoding.ASCII.GetString(adressBytes);
                            hostData.port              = int.Parse(System.Text.ASCIIEncoding.ASCII.GetString(portBytes));
                            hostData.gameName          = System.Text.UTF8Encoding.UTF8.GetString(nameBytes);
                            hostData.passwordProtected = passwordRequired > 0 ? true : false;
                            hostData.connectedPlayers  = playerCount;
                            hostData.playerLimit       = playerLimit;
                            hostData.useNat            = useNat > 0 ? true : false;
                            hostData.guid              = System.Text.ASCIIEncoding.ASCII.GetString(playerGUIDBytes);

                            this.hostData.Add(hostData);
                        }

                        break;

                    default:
                        UnityEngine.Debug.Log("Unknown action from MasterServer: " + action);
                        this.socketStream.Close();
                        break;
                    }
                }
            }
        }