コード例 #1
0
        private void Controller_OnRelationshipRemoved(object sender, SchemaEventArgs <Connection> e)
        {
            Connection connection = e.Entity;

            connection.RemoveFromSurface(this);
            OnConnectionRemoved.RaiseEvent(this, new SchemaEventArgs <Connection>(connection));
        }
コード例 #2
0
 public void Close(ProxyConnection connection)
 {
     if (ConnectionIndecies.TryRemove(connection, out var id))
     {
         IndexConnections.TryRemove(id, out connection);
         OnConnectionRemoved?.Invoke(this, connection);
         DisposeConnection(connection);
     }
 }
コード例 #3
0
 public ControllerImpl()
 {
     Schema = new Schema();
     Schema.OnConnectionAdded   += (s, e) => OnConnectionAdded.RaiseEvent(this, e);
     Schema.OnConnectionRemoved += (s, e) => OnConnectionRemoved.RaiseEvent(this, e);
     Schema.OnShapeAdded        += (s, e) => OnShapeAdded.RaiseEvent(this, e);
     Schema.OnShapeRemoved      += (s, e) => OnShapeRemoved.RaiseEvent(this, e);
     Schema.OnSchemaCleared     += (s, e) => OnSchemaCleared.RaiseEvent(this);
 }
コード例 #4
0
 public void Close(long id)
 {
     if (IndexConnections.TryRemove(id, out var connection))
     {
         if (ConnectionIndecies.TryRemove(connection, out id))
         {
             OnConnectionRemoved?.Invoke(this, connection);
             DisposeConnection(connection);
         }
     }
 }
コード例 #5
0
ファイル: RtspServer.cs プロジェクト: zebemce/VideoGate
        protected void ProcessConnectionRemoved(Guid connectionId, VideoSource videoSource)
        {
            if (videoSource != null)
            {
                OnConnectionRemoved?.Invoke(connectionId, videoSource);
            }

            lock (_rtspList)
            {
                _rtspList.RemoveAll(c => c.Id == connectionId);
            }
        }
        private void MonitorStreams()
        {
            while (IsRunning)
            {
                foreach (var client in Connections.ToList())
                {
                    if (!client.IsSocketConnected())
                    {
                        var e5 = BuildEvent(client, null, String.Empty);
                        Connections.Remove(client);
                        OnConnectionRemoved?.Invoke(this, e5);
                        continue;
                    }

                    if (client.Socket.Available != 0)
                    {
                        var readObject = ReadObject(client.Socket);
                        var e1         = BuildEvent(client, null, readObject);
                        OnPacketReceived?.Invoke(this, e1);

                        if (readObject is PingPacket ping)
                        {
                            client.SendObject(ping).Wait();
                            continue;
                        }

                        if (readObject is PersonalPacket pp)
                        {
                            var destination = Connections.FirstOrDefault(c => c.ClientId.ToString() == pp.GuidId);
                            var e4          = BuildEvent(client, destination, pp);
                            OnPersonalPacketReceived?.Invoke(this, e4);

                            if (destination != null)
                            {
                                destination.SendObject(pp).Wait();
                                var e2 = BuildEvent(client, destination, pp);
                                OnPersonalPacketSent?.Invoke(this, e2);
                            }
                        }
                        else
                        {
                            foreach (var c in Connections.ToList())
                            {
                                c.SendObject(readObject).Wait();
                                var e3 = BuildEvent(client, c, readObject);
                                OnPacketSent?.Invoke(this, e3);
                            }
                        }
                    }
                }
            }
        }
コード例 #7
0
 internal void RemoveConnection(Connection connection)
 {
     _connections.Remove(connection.id);
     MarkDirty();
     OnConnectionRemoved?.Invoke(connection);
 }