예제 #1
0
        public async Task <bool> Login()
        {
            try
            {
                HttpResponseMessage response = await httpUtil.PostFormAsync(LOGIN_URL, new Dictionary <string, string>()
                {
                    { "email", Email },
                    { "passwd", Password },
                    { "code", "" },
                    { "remember_me", "week" }
                }).ConfigureAwait(false);

                if (!(response.StatusCode == HttpStatusCode.OK))
                {
                    return(false);
                }

                var body = Newtonsoft.Json.JsonConvert.DeserializeObject <JObject>(await response.Content.ReadAsStringAsync());
                var ret  = body.Value <int>("ret");
                var msg  = body.Value <string>("msg");

                LoginStatusEvent?.Invoke(Email, ret, msg);
                Console.WriteLine(body.ToString());

                if (ret == 1)
                {
                    this.LoginStatus = true;
                    return(true);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
            return(false);
        }
 ///<summary>
 ///    The constructor creates the channels, and the null
 ///    sound, but doesn't make any of the channels active.
 ///
 ///    It should take name/value pair command-line args in an
 ///    string[] container, like main args
 ///</summary>
 private VoiceManager(FMOD.System fmod, Object[] parmArray, ConnectToServerEvent connectEvent, LoginStatusEvent loginStatusEvent, bool runningVoiceBot, string[] playbackFiles)
 {
     log.Info(null, "VoiceManager constructor: " + StringifyParms(parmArray));
     if (connectEvent != null)
         onConnectedToServer += connectEvent;
     if (loginStatusEvent != null)
         onLoginStatusReceived += loginStatusEvent;
     this.parameters = parmArray;
     this.runningVoiceBot = runningVoiceBot;
     this.playbackFiles = playbackFiles;
     currentVoiceParms = new VoiceParmSet(parmArray);
     string MyDocumentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
     string ClientAppDataFolder = Path.Combine(MyDocumentsFolder, "Multiverse World Browser");
     logFolder = Path.Combine(ClientAppDataFolder, "Logs");
     log.Debug(null, "VoiceManager constructor: Applying parms");
     playerListenerProperties = new ListenerProperties();
     playerListenerProperties.Init();
     ApplyConstructorParms(currentVoiceParms);
     ApplyPlaybackSettings(currentVoiceParms, false);
     log.Debug(this, "VoiceManager constructor: Encaching sound sources");
     voiceChannels = new Dictionary<Byte, VoiceChannel>();
     micChannels = new MicrophoneChannel[1];
     if (!runningVoiceBot) {
         if (fmod != null) {
             log.Debug(this, "VoiceManager constructor: Using fmod instance passed in: " + fmod);
             this.fmod = fmod;
         }
         else {
             log.Debug(this, "VoiceManager constructor: Creating new fmod instance");
             InitFmod();
         }
     }
     log.Debug(this, "VoiceManager constructor: Creating mic channel");
     micChannels[0] = new MicrophoneChannel(this, playerOid, micDeviceNumber, micRecordWAV, micRecordSpeex);
     recentSpeakers = new List<VoiceChannel>();
     noSoundShorts = new short[defaultSamplesPerFrame * 8];
     MaybeDeleteRecordedFile(micRecordWAV, LogFolderPath("RecordMic.wav"));
     MaybeDeleteRecordedFile(micRecordSpeex, LogFolderPath("RecordMic.speex"));
     ApplyGroupParms(currentVoiceParms, false);
     if (runningVoiceBot)
         log.DebugFormat(this, "VoiceManager constructor: Running voice bot oid {0}", playerOid);
     if (connectToServer) {
         log.Debug(this, "VoiceManager constructor: Initializing connection to server at " +
             voiceServerHost + ", port " + voiceServerPort);
         receiveBuffer = new byte[receiveBufferSize];
         connectedToServer = true;
         InitializeVoiceServerConnection();
     }
     else
         micChannels[0].InitMicrophone(currentVoiceParms, false);
 }