public void Remove(PeerProxy proxy) { lock (_connections) { _connections[proxy].Networks.Clear(); _connections.Remove(proxy); } }
public void ForEachNetwork(PeerProxy proxy, Action<NetworkManager, RemotePeer> action) { List<KeyValuePair<NetworkManager, RemotePeer>> tmpList = new List<KeyValuePair<NetworkManager, RemotePeer>>(); lock (_connections) tmpList.AddRange(_connections[proxy].Networks); foreach (KeyValuePair<NetworkManager, RemotePeer> pair in tmpList) { action(pair.Key, pair.Value); } }
public RemotePeer GetOrCreatePeer(NetworkManager net, PeerProxy proxy) { RemotePeer retValue; lock (_connections) { ConnProperties prop; if (_connections.TryGetValue(proxy, out prop)) { // polaczenie juz istnieje retValue = prop.GetOrRegister(net); } else { // polaczenie jeszcze nie wpisane do mapy prop = new ConnProperties(_managerHigher, proxy); retValue = prop.GetOrRegister(net); _connections.Add(proxy, prop); } } return retValue; }
public ProxyAsyncState(PeerProxy peerProxy, object state) { _peerProxy = peerProxy; _state = state; _waitHandle = new ManualResetEvent(false); }
private void ReceivingCallback(PeerProxy proxy) { try { object obj = proxy.Connection.EndReceive(); proxy.TryRestartTimer(); if (ObjectReceived != null) { ObjectReceived(proxy, obj); } } catch (Exception) { HandleDisconnect(proxy, true); // throw new ConnectionClosedException(); } }
public ConnectionAsyncResult(TcpClient client, PeerProxy proxy, object state) : base(proxy, state) { _client = client; }
private void HandleDisconnect(PeerProxy proxy, bool fireEvent) { Console.WriteLine("HandleDisconnect"); try { lock (_connections) { AsyncConnection connection = proxy.Connection; IPEndPoint endpoint = (IPEndPoint) connection.Client.Client.LocalEndPoint; _connections.Remove(endpoint); proxy.Dispose(); if (fireEvent && ConnectionClosed != null) { ConnectionClosed(proxy); } } } catch (ObjectDisposedException) { // Socket jest juz zamkniety } }
public ConnProperties(ConnectionManagerHigher managerHigher, PeerProxy proxy) { _managerHigher = managerHigher; _proxy = proxy; _owners = new Dictionary<NetworkManager, RemotePeer>(); }
public RemotePeer(ConnectionManagerHigher managerHigher, PeerProxy proxy) { _managerHigher = managerHigher; _proxy = proxy; }