public void OnClientEvent( object o, ClientEventArgs a ) { foreach( object arg in a.Args ) { GameToControllerWindowMessage msg = (GameToControllerWindowMessage)arg; ReadMessage(msg); } }
public void TestDefaultSerialization() { var original = new ClientEventArgs(); var serialized = JsonSerialization.Minimal.Serialize(original); var deseralized = JsonSerialization.Minimal.Deserialize<ClientEventArgs>(serialized); Assert.IsNotNull(deseralized.Then); Assert.IsNotNull(deseralized.Now); Assert.IsNotNull(deseralized.Stamp); Assert.AreEqual(ConnectionState.ConnectionDisconnected, deseralized.ConnectionState); Assert.AreEqual(ClientEventType.None, deseralized.EventType); }
/// <summary> /// Occurs when this client disconnected from the remote server. /// </summary> /// <param name="e">EventArgs.</param> protected virtual void OnDisconnectedFromServer(ClientEventArgs e) { if (DisconnectedFromServer != null) { Control target = DisconnectedFromServer.Target as Control; if (target != null && target.InvokeRequired) { target.Invoke(DisconnectedFromServer, new object[] { this, e }); } else { DisconnectedFromServer(this, e); } } }
private void Server_ClientDisconnected(object sender, ClientEventArgs e) { var list = new List <ClientInfo>(Clients); var client = list.Find(c => c.Owner == e.Client); if (client == SelectedClient) { SelectedClient = null; } Application.Current.Dispatcher.Invoke(() => { Clients.Remove(client); }); }
void RemoteClient_onClientDisconnected(object sender, ClientEventArgs e) { #if DEBUG Console.WriteLine("Remote DC'd"); #endif if (disconnected) { return; } //Console.WriteLine("Remote DC'd"); disconnected = true; Client.Client.Disconnect(); Client.Client.onDataReceived -= Client_onDataReceived; Client.Client.onClientDisconnected -= Client_onClientDisconnected; }
void RemoteClientClientDisconnecting(object sender, ClientEventArgs e) { if (disconnected) { return; } Console.WriteLine("\tremote DC'd @" + RemoteClient.Sock.RemoteEndPoint); disconnected = true; // Client.Client.Disconnect(); OnTunnelDisposing(); }
private void OnClientRegistration(object sender, ClientEventArgs e) { if (e.clientRegMessage == "You has been registered") { MessageBox.Show(e.clientRegMessage, "Registration Information", MessageBoxButton.OK, MessageBoxImage.Information); loginPresenter.LoginTB = RegistrationLoginTB; loginPresenter.SecurePassword = SecurePassword; loginPresenter.LoginCommand.Execute(null); // When user proper register -> make autologin to show window of activation code CloseAction(); // And close registration window } else { MessageBox.Show(e.clientRegMessage, "Registration Information", MessageBoxButton.OK, MessageBoxImage.Information); App.Client.strName = null; }; }
private void OnSendActivateCodeFromEmail(object sender, ClientEventArgs e) { if (e.clientSendActivCodeFromEmail == "You must activate your account first.") { MessageBoxResult result = MessageBox.Show(e.clientSendActivCodeFromEmail, "Confirmation", MessageBoxButton.OK, MessageBoxImage.Question); if (result == MessageBoxResult.OK) { ActivationUserWindow activateWindow = new ActivationUserWindow(); activateWindow.Show(); } } else { MessageBox.Show(e.clientSendActivCodeFromEmail, "Information", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void MainThreadListViewLog(string sender, ClientEventArgs e) { ListViewItem listview = new ListViewItem(); int stt = listView_log.Items.Count; listview.Text = stt.ToString(); var datas = e.package.data.Split('|'); //listview.SubItems.Add(datas[0]); //clientID của ng gửi //datas[1] = lenh //datas[2] = ng nhan listview.SubItems.Add(datas[3]); //nội dung tin nhắn listView_log.Items.Add(listview); listView_log.Items[stt].EnsureVisible(); }
private void ClientConnected(object sender, ClientEventArgs clientEventArgs) { var slave = new Slave(clientEventArgs.Client); Trace.WriteLine( String.Format("[{0}] Connected :D", slave.Client.RemoteEndPoint), "Commander.ClientConnected()"); slave.Client.PacketReceived += PacketReceived; slave.Client.PacketSent += PacketSent; _slaves.Add(slave.Client.ClientHandle, slave); slave.Client.SendPacket(new RequestInfoPacket()); SlaveConnected(this, new SlaveEventArgs(slave)); clientEventArgs.Client.ReceivePacketAsync(); }
private void server_ClientConnected(object sender, ClientEventArgs e) { if (InvokeRequired) { Invoke(new MiniHttpd.HttpServer.ClientEventHandler(server_ClientConnected), new object[] { sender, e }); return; } //Why isn't there a ListViewItem(int columns) constructor? -_- ListViewItem item = new ListViewItem(EmptyStrings(transferView.Columns.Count)); item.SubItems[clientColumn.Index].Text = e.HttpClient.RemoteAddress; clients.Add(e.HttpClient, item); transferView.Items.Add(item); }
private void BtnRemove_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show( "Информация о клиенте будет безвозвратно удалено, вы действительно хотите продолжить?", "Удаление клиента из БД", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); if (dr == System.Windows.Forms.DialogResult.OK) { ClientEventArgs clEvArg = new ClientEventArgs((Client)lbClients.SelectedItem); if (ClientDeleted != null) { ClientDeleted(this, clEvArg); } } }
private void BtnChangeInfo_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show( "Вы действительно хотите изменить информацию о клиенте?", "Изменение информации о клиенте", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); if (dr == System.Windows.Forms.DialogResult.OK) { ClientEventArgs cEvArg = new ClientEventArgs((Client)lbClients.SelectedItem); if (ClientInformationChanged != null) { ClientInformationChanged(this, cEvArg); } } }
public bool Connect() { if (active) return true; try { client = new TcpClient(); client.SendBufferSize = 200000; client.NoDelay = true; IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ip), port); active = false; client.Connect(serverEndPoint); ClientEventArgs mes = new ClientEventArgs(); mes.message = "Connected"; if (get_event != null) get_event(mes); active = true; System.Threading.Thread clientThread = new System.Threading.Thread(new System.Threading.ThreadStart(HandleClientComm)); clientThread.Start(); return true; } catch (System.Exception ex) { ClientEventArgs mes = new ClientEventArgs(); mes.message = "Timeout"; if (get_event != null) get_event(mes); client = null; name = ""; active = false; } return false; }
private void OnClientDeleteChannel(object sender, ClientEventArgs e) { if (e.clientChannelMsg2 != "Deny") { if (Lobbies.Contains(e.clientChannelMsg)) { lobbies.Remove(e.clientChannelMsg); } if (JoinedChannelsList.Contains(e.clientChannelMsg)) { joinedChannelsList.Remove(e.clientChannelMsg); } MessageBox.Show(e.clientChannelMsg2 + " deleted channel " + e.clientChannelMsg, "Gold Chat: " + User.strName, MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show(e.clientChannelMsg, "Gold Chat: " + User.strName, MessageBoxButton.OK, MessageBoxImage.Stop); } }
private void OnClientBanFromServer(object sender, ClientEventArgs e) { if (e.clientName != User.strName) { if (usersConnected.Contains(e.clientName)) { usersConnected.Remove(e.clientName); } if (friendlyUsersConnected.Contains(e.clientName)) { friendlyUsersConnected.Remove(e.clientName); } } else if (e.clientName == User.strName) { MessageBox.Show(e.clientBanReason, "Gold Chat: " + User.strName, MessageBoxButton.OK, MessageBoxImage.Stop); CloseAction(); } }
private void OnClientJoinChannel(object sender, ClientEventArgs e) { if (e.clientChannelMsg == "Send Password" || e.clientChannelMsg == "Wrong Password") { GenerateChannelPassWindow sendPassword = new GenerateChannelPassWindow(); JoinChannelSend.ChannelName = e.clientChannelName; sendPassword.OnClickOrEnter += JoinChannelSend.OnClickOrEnter; sendPassword.createWindow("Send Password: "******"Send Password to channel " + e.clientChannelName + " for join"); } else if (e.clientChannelMsg2 == "ChannelJoined" && !joinedChannelsList.Contains(e.clientChannelName)) { joinedChannelsList.Add(e.clientChannelName); MessageBox.Show(e.clientChannelMsg, "Gold Chat: " + User.strName, MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show(e.clientChannelMsg, "Gold Chat: " + User.strName, MessageBoxButton.OK, MessageBoxImage.Information); } }
private static async Task OnClientConnected(ClientEventArgs e, SpotifyClient spotify, RaspifyServer server) { console.PushLogMessage($"Client connected {e.EndPoint}"); var currentlyPlaying = await spotify .Player .GetCurrentlyPlaying(new() { Market = "from_token" }); if (currentlyPlaying is null) { console.PushLogMessage("Nothing playing"); return; } var track = CurrentTrack .From(currentlyPlaying) .ToString(); await server.SendAllAsync(track); }
private void OnClientTimeout(object sender, ClientEventArgs e) { //Raise an event that a client has timed out try { //Notify clients for last chance to use client object before it is closed if (this.ClientTimeout != null) { this.ClientTimeout(this, e); } lock (this.mClients) { this.mClients.Remove(e.Client.SessionID); } e.Client.Close(); } catch (Exception ex) { if (this.Error != null) { this.Error(this, new ErrorEventArgs(ex)); } } }
void view_CreateClientCard(object sender, EventArgs e) { ClientEventArgs clArg = (ClientEventArgs)e; Client client = clArg.client; try { clientCardCreator.MakeClientCard(client); messager.SuccessMessage(string.Format("Карта абонента \"{0}\" успешно создана.", client)); } catch (Exception exc) { messager.ErrorMessage(string.Format("{0}{1}{1}{2}{1}{3}", exc.Message, Environment.NewLine, exc.TargetSite, exc.StackTrace )); } }
/// <summary> /// Intercepter un évenement, puis créer un ServerToolsEvent correspondant à son type. /// </summary> private void HandleClientEvents(object sender, ClientEventArgs e) { ClientToolsEvent sta = null; Message msg = MessageUtil.decoder(e.Msg); ClientToolsEvent.typeEvent type = ClientToolsEvent.typeEvent.MESSAGE; if (msg.ListParams.Count > 0) { if (DataUtils.isErrorMessage(msg.ListParams[0])) { type = ClientToolsEvent.typeEvent.ERROR; } else if (msg.ListParams[0] == DataUtils.EXTINCTION_CODE) { type = ClientToolsEvent.typeEvent.EXTINCTION; } } sta = new ClientToolsEvent(type, msg.ListParams, msg.Stamp); clientToolsReceiveEvent(this, sta); }
void ServerClientConnected(object sender, ClientEventArgs e) { #if DEBUG Console.WriteLine("New Client :"); #endif //call plugins related to ClientConnectedHandler. foreach (ClientConnectedHandler cch in PluginLoader.LoadPlugin(typeof(ClientConnectedHandler))) { if (cch.Enabled) { try { if (!cch.OnConnect(e.Client, (IPEndPoint)e.Client.Sock.RemoteEndPoint)) { e.Client.Disconnect(); return; } } catch { } } } SocksClient client = new SocksClient(e.Client); e.Client.onDataReceived += Client_onDataReceived; e.Client.onDataSent += Client_onDataSent; client.onClientDisconnected += client_onClientDisconnected; Clients.Add(client); try { client.Start(this.PacketSize, this.Timeout); } catch (ObjectDisposedException ex) { Console.WriteLine(ex.Message); Clients.Remove(client); client.Dispose(); client = null; } }
private void Client_MessageReceived(object sender, ClientEventArgs e) { var datas = e.package.data.Split('|'); switch (datas[1]) { case "pm": { MainThreadOperation temp = MainThreadListViewLog; this.Invoke(temp, "MessageReveived", e); } break; case "f": { MainThreadOperation temp = MainThreadReceiveFile; this.Invoke(temp, "", e); } break; } }
private void OnClientClosed(object sender, ClientEventArgs e) { lock (clientLock) { // remove channel from our internal list for (int i = 0; i < clients.Count; i++) { if (clients[i].ConnectionID == e.ClientConnection.ConnectionID) { clients.RemoveAt(i); break; } } EventHandler <ClientEventArgs> handler = ChannelClosed; if (handler != null) { handler(this, e); } } }
private static void ClientUnloaded(object sender, ClientEventArgs e) { e.Client.ClientUnloaded -= ClientUnloaded; if (!e.Client.Silent) { OnClientUnloaded(e.Client.AccountName); } lock (CheckLock) { if (LoginClients.Contains(e.Client)) { LoginClients.Remove(e.Client); } else if (GameClients.Contains(e.Client)) { GameClients.Remove(e.Client); } } }
private void OnConnected(object sender, ClientEventArgs e) { //Raise an event that a client is connected try { //Add the new client to the collection of attached clients TcpClientProxy client = e.Client; lock (this.mClients) { this.mClients.Add(client.SessionID, client); } } catch (Exception ex) { if (this.Error != null) { this.Error(this, new ErrorEventArgs(ex)); } } finally { if (this.ClientConnected != null) { this.ClientConnected(this, e); } } }
private void OnMessageReceived(object sender, ClientEventArgs<TwitchMessage> e) { if (e.Argument.Type == TwitchMessageType.Common) { AddMessageToMessageList(e.Argument.Channel, e.Argument.Sender, e.Argument.Message, Color.Black); return; } if (e.Argument.Type == TwitchMessageType.Error) { AddMessageToMessageList("CLIENT", "Error", e.Argument.Message, Color.Blue); return; } if (e.Argument.Type == TwitchMessageType.LoginError) { AddMessageToMessageList("CLIENT", "Login-Error", e.Argument.Message, Color.Red); Logout(); UpdateChannelList(); return; } }
private void MainThreadReceiveFile(string sender, ClientEventArgs e) { var datas = e.package.data.Split('|'); if (datas[0] == clientID) { return; } var data = datas[3]; SaveFileDialog temp = new SaveFileDialog(); temp.OverwritePrompt = true; temp.InitialDirectory = ""; if (temp.ShowDialog() == DialogResult.OK) { var filecontent = Encoding.UTF8.GetBytes(data); File.WriteAllBytes(temp.FileName, filecontent); } }
private void NotesTab_TextCommandReceived(object sender, ClientEventArgs <string> e) { if (e.Value.ToLower().Equals(".close")) { Dispose(); } else if (e.Value.ToLower().Equals(".clear")) { RichTextBox.Clear(); } else if (e.Value.ToLower().Equals(".copy")) { if (!string.IsNullOrEmpty(RichTextBox.Text)) { Clipboard.SetText(RichTextBox.Text); WriteMessage(mNotificationColor, "Messages have been copied to your clipboard."); } } else { WriteMessage(mMessageColor, e.Value); } }
private void OnReceiveLogExcep(object sender, ClientEventArgs e) { MessageBox.Show(e.receiveLogExpceMessage, "Login Information", MessageBoxButton.OK, MessageBoxImage.Error); }
/// <summary> /// Pump the messages sent by the game application /// </summary> public void PumpMessages() { while(true) { GameToControllerWindowMessage msg = OurGameToControllerPipe.GetMessage(); ClientEventArgs args = new ClientEventArgs(); object[] rargs = new object[1]; rargs[0] = msg; args.Args = rargs; if (msg == GameToControllerWindowMessage.ApplicationQuit) OnReceiveQuitMessage(); else mySongTestController.OnClientEvent(this, args); } }
private void StationController_ClientConnected(object sender, ClientEventArgs e) { Dispatcher.Invoke(() => IsEnabled = true); AppendLog($"Client connected: {e.ClientName}"); }
protected override void OnRequestTimeout(object sender, ClientEventArgs client) => Logger.LogInformation("Request was not executed in the specified timeout.");
void mc_get_message(ClientEventArgs args) { print(args.message); }
void read_process(string msg) { //PROTOCOL ANALISYS ClientEventArgs mes = new ClientEventArgs(); mes.message = msg; if (get_message != null) get_message(mes); }
private void OnClientStateChanged(object sender, ClientEventArgs<ClientState> e) { if (e.Argument == ClientState.FAILED) Logout(); }
public void Disconnect() { if (client != null && active) { active = false; client.Close(); client = null; ClientEventArgs mes = new ClientEventArgs(); mes.message = "Disconnected"; if (get_event != null) get_event(mes); } }
public void TestSingleDepthPopulationSerialization() { var original = new ClientEventArgs() { ConnectionState = ConnectionState.ConnectionLoggedIn, EventType = ClientEventType.ClientConnectionStateChange, Now = { Actions = new List<INetworkAction>() { new NetworkAction() { Uid = Guid.Empty } }, Exceptions = new List<String>() { "" }, Packets = new List<IPacket>() { new Packet() { Stamp = new DateTime(2000, 10, 10, 10, 10, 10) } } }, Then = { Actions = new List<INetworkAction>() { new NetworkAction() { Uid = Guid.Empty } }, Exceptions = new List<String>() { "" }, Packets = new List<IPacket>() { new Packet() { Stamp = new DateTime(2000, 10, 10, 10, 10, 10) } } } }; var serialized = JsonSerialization.Minimal.Serialize(original); var deseralized = JsonSerialization.Minimal.Deserialize<ClientEventArgs>(serialized); Assert.IsNotNull(deseralized.Then); Assert.IsNotNull(deseralized.Now); Assert.IsNotNull(deseralized.Stamp); Assert.AreEqual(ConnectionState.ConnectionLoggedIn, deseralized.ConnectionState); Assert.AreEqual(ClientEventType.ClientConnectionStateChange, deseralized.EventType); Assert.IsNotEmpty(deseralized.Then.Exceptions); Assert.IsNotEmpty(deseralized.Then.Packets); Assert.IsNotEmpty(deseralized.Then.Actions); Assert.IsNotEmpty(deseralized.Now.Exceptions); Assert.IsNotEmpty(deseralized.Now.Packets); Assert.IsNotEmpty(deseralized.Now.Actions); }
void server_clientArrivedEvent(object sender, ClientEventArgs e) { Session ses = new Session(e.client); LoginManager loginManager = new LoginManager(this, ses, dal); loginManager.launch(); Console.WriteLine("Client arrived and redirected to LoginManager. "); }
void server_clientRemovedEvent(object sender, ClientEventArgs e) { RemoveUser(e.client); }
protected void OnButton59ClientEvent(object o, ClientEventArgs args) { throw new NotImplementedException (); }
protected void OnButton1ClientEvent (object o, ClientEventArgs args) { }
protected virtual void OnClientInitialized(object sender, ClientEventArgs client) { }
protected virtual void OnRequestTimeout(object sender, ClientEventArgs client) { }
private void HandleClientComm() { TcpClient tcpClient = client; if (tcpClient == null) return; if (active) { NetworkStream clientStream = tcpClient.GetStream(); byte[] message = new byte[4096]; int bytesRead; while (active) { bytesRead = 0; try { bytesRead = clientStream.Read(message, 0, 4096); } catch { break; } if (bytesRead == 0) { break; } string read_str = Encoding.UTF8.GetString(message, 0, bytesRead); read_process(read_str); } active = false; ClientEventArgs mes = new ClientEventArgs(); mes.message = "Disconnected"; if (get_event != null) get_event(mes); if (tcpClient != null) { tcpClient.Close(); tcpClient = null; } } }