コード例 #1
0
        private void login(ConnectType type)
        {
            if (socket != null && socket.IsAlive)
            {
                return;
            }
            dynamic d = JsonConvert.DeserializeObject(RestApiClient.GETNOAUTH("gateway").Content);

            gateway          = Convert.ToString(d.url);
            ConnectionStatus = Connection.LOGGING_IN;
            socket           = new WebSocket($"{gateway}/?v={api_version}&encoding={encoding}&client_id=430746509714259989");
            CarrotcordLogger.log(CarrotcordLogger.LogSource.WEBSOCKET, $"[CONNECTING] {gateway}, version: {api_version}, encoding: {encoding}");
            socket.ConnectAsync();
            if (type == ConnectType.NORMAL)
            {
                socket.OnOpen += Socket_OnOpenNormal;
            }
            else if (type == ConnectType.RESUME)
            {
                ConnectionStatus   = Connection.RESUMING;
                retryTimer.Enabled = false;
                socket.OnOpen     += Socket_OnOpenResume;
            }
            socket.OnClose   += Socket_OnClose;
            socket.OnMessage += Socket_OnMessage;
        }