public void CommandSpotifySearch(ClientCall invoker, string type, string content) { if (!checkControlAvailable(invoker)) { return; } if (type == "playlist" || type == "pl") { lock (_lock) { activeSpotifyControl.searchPlaylist(content, (string ret) => { informChannel(Ts3Client, ret); }); } } else if (type == "album") { lock (_lock) { activeSpotifyControl.searchAlbum(content, (string ret) => { informChannel(Ts3Client, ret); }); } } else { informChannel(Ts3Client, "No search command found"); } }
public void LoginStepTwo(SpotifyAccount account, ClientCall invoker) { //get Email string information = ""; information += "Now your Spotify-E-Mail."; Ts3Client.SendMessage(information, invoker.ClientId.Value); void handler(object sender, TextMessage textMessage) { if (textMessage.InvokerId == invoker.ClientId) { string mail = textMessage.Message.ToString(); Match m = Regex.Match(mail, @"\[URL=.*\](.*)\[\/URL\]"); if (m.Success) { account.email = m.Groups[m.Groups.Count - 1].Value; } else { account.email = mail; } Ts3Client.OnMessageReceived -= handler; LoginStepThree(account, invoker); } }; Ts3Client.OnMessageReceived += handler; }
public void BroadCastMessageTest() { ClientCall remoteCall = null; // TODO: Initialize to an appropriate value SseHelper.BroadCastMessage(remoteCall); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public string CommandSpotifyAccountEdit(ClientCall invoker, string property) { SpotifyAccount account = spotifyPluginConfig.getAccount(invoker.ClientUid.Value); if (!account.Exists()) { return("No account found."); } property = property.ToLower(); if (property == "pass" || property == "password" || property == "passwort") { LoginStepThree(account, invoker); //follow it, we dont store passwords } else if (property == "auth") { LoginStepOne(account, invoker); } else { return("Not found."); } return(""); }
public TwoWayResult AcceptChallenge(Guid challengeId) { //get the challenge var match = factory.GetGame().AcceptChallenge(challengeId); //inform the challenger that the challenge was accepted string clientId = factory.GetPlayerPresence().GetClientId(match.Item2); if (!string.IsNullOrWhiteSpace(clientId)) { //Clients[clientId].challengeAccepted(match.Item1); //The client accepted the challenge dynamic call1 = new ClientCall { CallerId = Context.ConnectionId, ClientId = clientId }; call1.game.challengeAccepted(match.Item1); RemoteExecution.ExecuteOnClient(call1); //Caller.goToGame(match.Item1); //Tell the caller to go to the match dynamic call2 = new ClientCall { CallerId = Context.ConnectionId, ClientId = Context.ConnectionId }; call2.game.goToGame(match.Item1); return(new TwoWayResult(call2)); } else { //Caller.otherPlayerNotOnline(); dynamic call = new ClientCall { CallerId = Context.ConnectionId, ClientId = Context.ConnectionId }; call.game.otherPlayerNotOnline(); return(call); } }
public string commandSpotifyPlay(ClientCall invoker, IVoiceTarget targetManager, string id) { if (!spotifyPluginConfig.librespotExists()) { return("Please check Librespot-Path"); } if (id == "") { return("nothing given."); } if (!checkControlAvailable(invoker)) { return("SpotifyControl error."); } if (spotifyInstance == null) { bool producerStarted = startProducer(targetManager); if (!producerStarted) { return("Librespot error."); } } changeMusic(id); return(""); }
public bool _startControl(ClientCall invoker) { if (activeSpotifyAccount != null) { return(false); } SpotifyAccount account = spotifyPluginConfig.getAccount(invoker.ClientUid.Value); if (!account.Exists()) { return(false); } SpotifyControl tempControl = new SpotifyControl(spotifyPluginConfig, rootConf); tempControl._refreshtoken(account.refreshToken).Wait(); if (!tempControl.hasInit()) { return(false); } activeSpotifyAccount = account; activeSpotifyAccount.setClient(invoker.ClientId.ToString()); activeSpotifyControl = tempControl; activeSpotifyControl.setTimer(activeSpotifyAccount.refreshToken); return(true); }
public void TwoWayResultConstructorTest() { ClientCall call = null; // TODO: Initialize to an appropriate value TwoWayResult target = new TwoWayResult(call); Assert.Inconclusive("TODO: Implement code to verify target"); }
private void tmrTimeOut_Tick(object sender, EventArgs e) { if (isWait) { WaitDelay++; if (WaitDelay > 2) { if (WaitType == 1) { ClientCall.软件版本请求指令(Program.MyGuid, Program.StoreID, 1); isWait = true; WaitDelay = 0; WaitType = 1; } else if (WaitType == 2) { ClientCall.载文件("update\\" + Program.CurDownload); WaitType = 3; WaitDelay = 0; isWait = true; } else if (WaitType == 3) { Console.WriteLine("下载超时"); //WaitType = 2; ClientCall.文件下载超时(); WaitDelay = 0; } } } }
public void BroadcastExecuteOnClientTest() { ClientCall remoteCall = null; // TODO: Initialize to an appropriate value RemoteExecution.BroadcastExecuteOnClient(remoteCall); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public void RaiseConnectionLostEventTest() { ClientCall call = null; // TODO: Initialize to an appropriate value RemoteExecutionController.RaiseConnectionLostEvent(call); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public void RpcUIvarUpdate(string prizepool) { GameObject cc = GameObject.Find("ClientCall"); ClientCall clientcall = cc.GetComponent <ClientCall>(); clientcall.przepoolui(prizepool); }
public void LoginStepOne(SpotifyAccount account, ClientCall invoker) { //get Auth-Key account.id = invoker.ClientUid.Value; var newControl = new SpotifyControl(spotifyPluginConfig, rootConf); newControl.firstTimeLogin((link) => { string information = ""; information += "Grant rights and place the code from GET-Param into this chat."; Ts3Client.SendMessage(information, invoker.ClientId.Value); Ts3Client.SendMessage(link, invoker.ClientId.Value); void handler(object sender, TextMessage textMessage) { if (textMessage.InvokerId == invoker.ClientId) { account.code = textMessage.Message.ToString(); Ts3Client.OnMessageReceived -= handler; LoginStepTwo(account, invoker); } }; Ts3Client.OnMessageReceived += handler; }); }
internal static bool SendMessage(ClientCall remoteCall, bool throwException = true) { if (remoteCall == null) throw new ArgumentNullException("remoteCall"); //check if the id exists if (!clientStreams.ContainsKey(remoteCall.ClientId)) { if (throwException) throw new Exception("ClientId does not exist"); else return false; } //get the stream var st = clientStreams[remoteCall.ClientId]; try { st.WriteLine(string.Concat ("data:", remoteCall.ToString() , "\n")); st.Flush(); } catch (Exception e) { //its very likely that the client its has been disconnected if an exception occurs return false; } return true; }
void TwoWayController_ConnectionLost(ClientCall call) { //remove it from the logged users UserHelper.UserLogoff(call.ClientId); //tell everybody to reload the userlist ReloadUserList(); }
public async Task<Auditor> TraceElasticsearchException(ClientCall callTrace, Action<ElasticsearchClientException> assert) { this._cluster = _cluster ?? this.Cluster(); this._cluster.ClientThrows(true); this.AssertPoolBeforeCall?.Invoke(this._cluster.ConnectionPool); Action call = () => this._cluster.ClientCall(callTrace?.RequestOverrides); var exception = call.ShouldThrowExactly<ElasticsearchClientException>() .Subject.First(); assert(exception); this.AuditTrail = exception.AuditTrail; this.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool); this._clusterAsync = _clusterAsync ?? this.Cluster(); this._clusterAsync.ClientThrows(true); Func<Task> callAsync = async () => await this._clusterAsync.ClientCallAsync(callTrace?.RequestOverrides); exception = callAsync.ShouldThrowExactly<ElasticsearchClientException>() .Subject.First(); assert(exception); this.AsyncAuditTrail = exception.AuditTrail; this.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool); var audit = new Auditor(_cluster, _clusterAsync); return await audit.TraceElasticsearchExceptionOnResponse(callTrace, assert); }
public JsonResult PushVideoFragment() { //Get the audio stream and store it on a local collection MemoryStream ms = new MemoryStream(); Request.Files[0].InputStream.CopyTo(ms); ms.Position = 0; string id = Guid.NewGuid().ToString().Replace("-", ""); audios.Add(id, ms); //store the images locally var frames = new List <string>(); foreach (string k in Request.Form.Keys) { frames.Add(Request.Form[k]); } //send the audio to everyone but me var receivers = RemoteController.Users.Where(u => u != Request.Cookies["videoChatUser"].Value); foreach (var u in receivers) { dynamic call = new ClientCall { CallerId = Request.Cookies["videoChatUser"].Value, ClientId = u }; //since we cannot send the audio, we just send the ID of the audio that we just received call.updateVideoFragment(id, frames, Request.Cookies["videoChatUser"].Value); RemoteExecution.ExecuteOnClient(call, false); } return(Json(new { success = true })); }
public void CommandSpotifyShuffle(ClientCall invoker) { if (!checkControlAvailable(invoker)) { return; } informChannel(Ts3Client, "Shuffle is " + (activeSpotifyControl.shuffle ? "on" : "off")); }
/// <summary> /// Perform the given call on all the connected clients /// </summary> /// <param name="remoteCall">Details of the call</param> public static void BroadcastExecuteOnClient(ClientCall remoteCall) { if (remoteCall == null) throw new ArgumentNullException("remoteCall"); //Send message to everyone SseHelper.BroadCastMessage(remoteCall); }
private static void BuildMethod(StringBuilder builder, ClientCall clientCall, CSharpOperationModel operation, bool cancellationToken) { builder.Append($"public {operation.ResultType} {operation.ActualOperationName}Async("); BuildParameters(builder, clientCall, operation, cancellationToken, false); builder.Append($") => Client.{operation.ActualOperationName}Async("); BuildParameters(builder, clientCall, operation, cancellationToken, true); builder.AppendLine(");"); }
public void ClientCallConstructorTest() { dynamic target = new ClientCall { CallerId = "Test", ClientId = "Test" }; Assert.Inconclusive("TODO: Implement code to verify target"); }
public void ExecuteOnClientTest() { ClientCall remoteCall = null; // TODO: Initialize to an appropriate value bool raiseEventOnError = false; // TODO: Initialize to an appropriate value RemoteExecution.ExecuteOnClient(remoteCall, raiseEventOnError); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public static void ReloadUserList() { dynamic reload = new ClientCall { CallerId = string.Empty, ClientId = string.Empty }; reload.getUsers(); RemoteExecution.BroadcastExecuteOnClient(reload); }
public void ExecuteResultTest() { ClientCall call = null; // TODO: Initialize to an appropriate value TwoWayResult target = new TwoWayResult(call); // TODO: Initialize to an appropriate value ControllerContext context = null; // TODO: Initialize to an appropriate value target.ExecuteResult(context); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public static void SendMessage(Ts3Client client, ClientCall cc, string message) { if (cc?.ClientId == null) { return; } client.SendMessage(message, cc.ClientId.Value); }
void CheckUpdate() { tmrUpdate.Enabled = false; switch (checkFlag) { case 0: //从磁盘检测 if (diskID > 5) { //lblInfo.Text = "未能从磁盘检测到更新"; checkFlag++; } else { string diskName = Convert.ToChar(67 + diskID).ToString(); //lblInfo.Text = "正在检测" + diskName + "盘"; if (File.Exists(diskName + ":\\" + Program.ProcessName + ".zip")) { //找到相关压缩包 tmrUpdate.Enabled = false; //lblInfo.Text = "正在解压缩..."; if (Directory.Exists(Application.StartupPath + "\\update\\unzip")) { DeletePath(Application.StartupPath + "\\update\\unzip"); } if (UnZip(diskName + ":\\" + Program.ProcessName + ".zip", Application.StartupPath + "\\update\\unzip", "", true)) { updateFlag++; tmrCheck.Enabled = true; } else { //lblInfo.Text = "文件解压失败"; Application.DoEvents(); Thread.Sleep(2000); Application.Exit(); } } diskID++; } break; case 1: //lblInfo.Text = "从网络检查更新..."; ClientCall.软件版本请求指令(Program.MyGuid, Program.StoreID, 1); isWait = true; WaitDelay = 0; WaitType = 1; RequestCount++; //if (RequestCount > 5) //Application.Exit(); break; } tmrUpdate.Enabled = true; }
public TwoWayResult SendMessageTo(string messageTo, string message) { dynamic call = new ClientCall { ClientId = messageTo, CallerId = User.Identity.Name }; //make the remote call call.messageReceived(User.Identity.Name, message, true); return(new TwoWayResult(call)); }
private bool checkControlAvailable(ClientCall invoker) { if (activeSpotifyControl != null && activeSpotifyControl.hasInit()) { return(true); } return(_startControl(invoker)); }
/// <summary> /// Execute the given call on the client /// </summary> /// <param name="remoteCall">The details of the call</param> /// <param name="raiseEventOnError">if false, no event will be raised if there is a communications problem</param> public static void ExecuteOnClient(ClientCall remoteCall, bool raiseEventOnError = true) { if (remoteCall == null) throw new ArgumentNullException("remoteCall"); if (!SseHelper.SendMessage(remoteCall,raiseEventOnError) && !raiseEventOnError) { //inform the user who made the call RemoteExecutionController.RaiseConnectionLostEvent(remoteCall); } }
public void ToStringTest() { ClientCall target = new ClientCall(); // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; actual = target.ToString(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
/// <summary> /// Perform the given call on all the connected clients /// </summary> /// <param name="remoteCall">Details of the call</param> public static void BroadcastExecuteOnClient(ClientCall remoteCall) { if (remoteCall == null) { throw new ArgumentNullException("remoteCall"); } //Send message to everyone SseHelper.BroadCastMessage(remoteCall); }
public void commandSpotifyStop(ClientCall invoker) { lock (_lock) { if (checkControlAvailable(invoker)) { activeSpotifyControl.stop(); } } // stopSpotify(); }
public void ChildTest() { ClientCall_Accessor target = new ClientCall_Accessor(); // TODO: Initialize to an appropriate value ClientCall expected = null; // TODO: Initialize to an appropriate value ClientCall actual; target.Child = expected; actual = target.Child; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void SendMessageTest() { ClientCall remoteCall = null; // TODO: Initialize to an appropriate value bool throwException = false; // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; actual = SseHelper.SendMessage(remoteCall, throwException); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
/// <summary> /// Performs the call in all the connected clients /// </summary> /// <param name="remoteCall">details of the call</param> internal static void BroadCastMessage(ClientCall remoteCall) { if (remoteCall == null) throw new ArgumentNullException("remoteCall"); foreach (var k in clientStreams.Keys) { if (k != remoteCall.CallerId) { remoteCall.ClientId = k; SendMessage(remoteCall,false); } } }
public async Task<Auditor> TraceStartup(ClientCall callTrace = null) { this._cluster = _cluster ?? this.Cluster(); this.AssertPoolBeforeCall?.Invoke(this._cluster.ConnectionPool); this.Response = this._cluster.ClientCall(callTrace?.RequestOverrides); this.AuditTrail = this.Response.ApiCall.AuditTrail; this.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool); this._clusterAsync = _clusterAsync ?? this.Cluster(); this.ResponseAsync = await this._clusterAsync.ClientCallAsync(callTrace?.RequestOverrides); this.AsyncAuditTrail = this.ResponseAsync.ApiCall.AuditTrail; this.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool); return new Auditor(_cluster, _clusterAsync); }
/// <summary> /// Sends a message to the proper client /// </summary> internal static bool SendMessage(ClientCall remoteCall, bool throwException = true) { if (remoteCall == null) throw new ArgumentNullException("remoteCall"); //check if the id exists if (!clientStreams.ContainsKey(remoteCall.ClientId)) { if (throwException) throw new Exception("ClientId does not exist"); else return false; } //remove the client id from the internal list if (ConnectionsMade.Contains(remoteCall.ClientId)) ConnectionsMade.Remove(remoteCall.ClientId); //get the stream var st = clientStreams[remoteCall.ClientId]; lock (st) { try { //always send an empty package first string data = string.Concat("data:", "-1", "\n\n"); st.WriteLine(data); st.Flush(); //then send the real message data = string.Concat("data:", remoteCall.ToString(), "\n\n"); st.WriteLine(data); st.Flush(); //always send an empty package at the end data = string.Concat("data:", "-1", "\n\n"); st.WriteLine(data); st.Flush(); ConnectionsMade.Add(remoteCall.ClientId); } catch (Exception e) { //its very likely that the client its has been disconnected if an exception occurs return false; } } return true; }
public async Task<Auditor> TraceCall(ClientCall callTrace, int nthCall = 0) { await this.TraceStartup(callTrace); return AssertAuditTrails(callTrace, nthCall); }
#pragma warning disable 1998 public async Task<Auditor> TraceUnexpectedException(ClientCall callTrace, Action<UnexpectedElasticsearchClientException> assert) #pragma warning restore 1998 { this._cluster = _cluster ?? this.Cluster(); this.AssertPoolBeforeCall?.Invoke(this._cluster.ConnectionPool); Action call = () => this._cluster.ClientCall(callTrace?.RequestOverrides); var exception = call.ShouldThrowExactly<UnexpectedElasticsearchClientException>() .Subject.First(); assert(exception); this.AuditTrail = exception.AuditTrail; this.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool); this._clusterAsync = _clusterAsync ?? this.Cluster(); Func<Task> callAsync = async () => await this._clusterAsync.ClientCallAsync(callTrace?.RequestOverrides); exception = callAsync.ShouldThrowExactly<UnexpectedElasticsearchClientException>() .Subject.First(); assert(exception); this.AsyncAuditTrail = exception.AuditTrail; this.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool); return new Auditor(_cluster, _clusterAsync); }
private Auditor AssertAuditTrails(ClientCall callTrace, int nthCall) { this.AuditTrail.Count.Should() .Be(this.AsyncAuditTrail.Count, "calling async should have the same audit trail length as the sync call"); AssertTrailOnResponse(callTrace, this.AuditTrail, true, nthCall); AssertTrailOnResponse(callTrace, this.AuditTrail, false, nthCall); callTrace?.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool); callTrace?.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool); return new Auditor(_cluster, _clusterAsync); }
private static void AssertTrailOnResponse(ClientCall callTrace, List<Audit> auditTrail, bool sync, int nthCall) { var typeOfTrail = (sync ? "synchronous" : "asynchronous") + " audit trail"; var nthClientCall = (nthCall + 1).ToOrdinal(); callTrace.Select(c=>c.Event).Should().ContainInOrder(auditTrail.Select(a=>a.Event), $"the {nthClientCall} client call's {typeOfTrail} should assert ALL audit trail items"); foreach (var t in auditTrail.Select((a, i) => new { a, i })) { var i = t.i; var audit = t.a; var nthAuditTrailItem = (i + 1).ToOrdinal(); var because = $"thats the {{0}} specified on the {nthAuditTrailItem} item in the {nthClientCall} client call's {typeOfTrail}"; var c = callTrace[i]; audit.Event.Should().Be(c.Event, string.Format(because, "event")); if (c.Port.HasValue) audit.Node.Uri.Port.Should().Be(c.Port.Value, string.Format(because, "port")); c.SimpleAssert?.Invoke(audit); c.AssertWithBecause?.Invoke(string.Format(because, "custom assertion"), audit); } callTrace.Count.Should().Be(auditTrail.Count); }
#pragma warning disable 1998 public async Task<Auditor> TraceElasticsearchExceptionOnResponse(ClientCall callTrace, Action<ElasticsearchClientException> assert) #pragma warning restore 1998 { this._cluster = _cluster ?? this.Cluster(); this._cluster.ClientThrows(false); this.AssertPoolBeforeCall?.Invoke(this._cluster.ConnectionPool); Action call = () => { this.Response = this._cluster.ClientCall(callTrace?.RequestOverrides); }; call.ShouldNotThrow(); this.Response.IsValid.Should().BeFalse(); var exception = this.Response.ApiCall.OriginalException as ElasticsearchClientException; exception.Should().NotBeNull("OriginalException on response is not expected ElasticsearchClientException"); assert(exception); this.AuditTrail = exception.AuditTrail; this.AssertPoolAfterCall?.Invoke(this._cluster.ConnectionPool); this._clusterAsync = _clusterAsync ?? this.Cluster(); this._clusterAsync.ClientThrows(false); Func<Task> callAsync = async () => { this.ResponseAsync = await this._clusterAsync.ClientCallAsync(callTrace?.RequestOverrides); }; callAsync.ShouldNotThrow(); this.ResponseAsync.IsValid.Should().BeFalse(); exception = this.ResponseAsync.ApiCall.OriginalException as ElasticsearchClientException; exception.Should().NotBeNull("OriginalException on response is not expected ElasticsearchClientException"); assert(exception); this.AsyncAuditTrail = exception.AuditTrail; this.AssertPoolAfterCall?.Invoke(this._clusterAsync.ConnectionPool); var audit = new Auditor(_cluster, _clusterAsync); return audit; }