Пример #1
0
        void System.IDisposable.Dispose()
        {
            if (_updateHandle != null)
            {
                EB.Coroutines.ClearUpdate(_updateHandle);
                _updateHandle = null;
            }

            if (_socket != null)
            {
                _socket.Dispose();
                _socket = null;
            }
        }
Пример #2
0
        public Manager(Config config)
        {
            if (Enabled == true)
            {
                _config       = config;
                _rpcs         = Johny.HashtablePool.Claim();
                _deferred     = new EB.Deferred(8);
                _updateHandle = EB.Coroutines.SetUpdate(_deferred.Dispatch);

                // load certs
                //EB.Net.TcpClientFactory.LoadCertStore("Crypto/Certs");

                // make the signed request
                Hashtable data = Johny.HashtablePool.Claim();
                data["_id"]       = EB.Version.GetMACAddress();
                data["type"]      = Application.platform.ToString();
                data["game"]      = _config.game;
                data["last"]      = EB.Time.Now;
                data["algorithm"] = "hmac-sha1";
                var json = EB.JSON.Stringify(data);

                var key = SignedRequest.Stringify(Encoding.GetBytes(json), Hmac.Sha1(Encoding.GetBytes(_config.serverKey)));

                var url = _config.serverUrl + "?access_token=" + key;
                _wsUrl = new EB.Uri(url);
                Debug.Log("GameTalk Url: " + url);

                _socket          = new EB.Net.TalkWebSocket();
                _socket.OnError += this.OnError;
                _socket.OnRPC   += this.OnRPC;

                Bind(string.Empty, new RPC.Global());

                ConnectIfNeeded();
            }
        }