コード例 #1
0
 private void ProtocolClient_ConnectionError(ProtocolClient sender, Exception exception)
 {
     lock (syncLock) {
         connectedClients.Remove(sender);
         ConnectionError?.Invoke(sender, exception);
     }
 }
コード例 #2
0
 private void ProtocolClient_ConnectionEstablished(ProtocolClient sender)
 {
     lock (syncLock) {
         connectedClients.Add(sender);
         ConnectionEstablished?.Invoke(sender);
     }
 }
コード例 #3
0
        private void AcceptCallBack(IAsyncResult iar)
        {
            try {
                Socket accepted = listeningSocket.EndAccept(iar);
                if (blockedHosts.Contains((accepted.RemoteEndPoint as IPEndPoint).Address.ToString()))
                {
                    accepted.Disconnect(false);
                    return;
                }
                accepted.NoDelay = true;
                ProtocolClient protocolClient = new ProtocolClient(accepted, ServerOptions.ClientOptions);

                protocolClient.ConnectionError        += ProtocolClient_ConnectionError;
                protocolClient.ConnectionEstablished  += ProtocolClient_ConnectionEstablished;
                protocolClient.PacketReceived         += ProtocolClient_PacketReceived;
                protocolClient.ReceiveProgressChanged += ProtocolClient_ReceiveProgressChanged;
                protocolClient.PacketSend             += ProtocolClient_PacketSend;
                protocolClient.DOSDetected            += ProtocolClient_DOSDetected;
                protocolClient.PingUpdated            += ProtocolClient_PingUpdated;

                protocolClient.Start();
                listeningSocket.BeginAccept(AcceptCallBack, null);
            } catch {
                //MessageBox.Show(ex.Message + " \n\n [" + ex.StackTrace + "]");
            }
        }
コード例 #4
0
 public void Broadcast(byte[] packet, ProtocolClient exception = null)
 {
     lock (syncLock) {
         for (int i = 0; i > connectedClients.Count; i++)
         {
             var client = connectedClients[i];
             if (client != exception)
             {
                 try {
                     client.Send(packet);
                 } catch { }
             }
         }
     }
 }
コード例 #5
0
 private void ProtocolClient_PacketReceived(ProtocolClient sender, PacketReceivedEventArgs PacketReceivedEventArgs)
 {
     PacketReceived?.Invoke(sender, PacketReceivedEventArgs);
 }
コード例 #6
0
 private void ProtocolClient_ReceiveProgressChanged(ProtocolClient sender, int bytesReceived, int bytesToReceive)
 {
     ReceiveProgressChanged?.Invoke(sender, bytesReceived, bytesToReceive);
 }
コード例 #7
0
 private void ProtocolClient_DOSDetected(ProtocolClient sender)
 {
     DOSDetected?.Invoke(sender);
 }
コード例 #8
0
 private void ProtocolClient_PacketSend(ProtocolClient sender, int Send)
 {
     PacketSend?.Invoke(sender, Send);
 }
コード例 #9
0
 private void ProtocolClient_PingUpdated(ProtocolClient sender, double ping)
 {
     PingUpdated?.Invoke(sender, ping);
 }