private void stopAndRemovePinger(HostAndPort peerHostAndPort) { Timer pinger; if (peerHostAndPortToPingerMap.TryGetValue(peerHostAndPort, out pinger)) { pinger.Dispose(); peerHostAndPortToPingerMap.Remove(peerHostAndPort); } }
public PeerPingerState(HostAndPort peerHostAndPort, ObjectPrx proxy, DirectConnectCommunicator comm) { this.peerHostAndPort = peerHostAndPort; this.proxy = proxy; this.comm = comm; }
private void notifyPeerOfDisconnection(HostAndPort peerHostAndPort) { TerkUserPrx terkUserPrx; peerHostAndPortToProxyMap.TryGetValue(peerHostAndPort, out terkUserPrx); if (terkUserPrx != null) { try { terkUserPrx.peerDisconnected(getMyUserId(terkUserPrx)); } catch (Exception e) { log("Exception while trying to notify peer [" + peerHostAndPort + "] of the disconnection"); } } }
private ObjectPrx getPeerProxy(HostAndPort peerHostAndPort, Identity proxyIdentity) { log("getPeerProxy called"); string protocol = communicator.getProperties().getProperty(PROTOCOL_PROPERTY_KEY); if (protocol == null || protocol.Length == 0) { protocol = DEFAULT_PROTOCOL; } string port; if (peerHostAndPort.getPort() != null) { port = peerHostAndPort.getPort(); } else { port = communicator.getProperties().getProperty(PORT_PROPERTY_KEY); } if (port == null || port.Length == 0) { port = DEFAULT_PORT; } StringBuilder proxyString = new StringBuilder("'"); proxyString.Append(Util.identityToString(proxyIdentity)); proxyString.Append("':"); proxyString.Append(protocol); proxyString.Append(" -h "); proxyString.Append(peerHostAndPort.getHost()); proxyString.Append(" -p "); proxyString.Append(port); log("Calling stringToProxy on: "+proxyString); ObjectPrx objectPrx = communicator.stringToProxy(proxyString.ToString()); log("stringToProxy returned"); // ensure that our custom context entries are passed along with every call on the proxy Context context = new Context(); context.Add(CONTEXT_MAP_KEY_PEER_IDENTITY, Util.identityToString(objectPrx.ice_getIdentity())); context.Add(CONTEXT_MAP_KEY_PEER_USERID, getMyUserId(objectPrx)); context.Add(CONTEXT_MAP_KEY_IS_DIRECT_CONNECT, "true"); return objectPrx.ice_context(context); }
private Dictionary<Identity, ObjectPrx> getPeerProxies(HostAndPort peerHostAndPort, List<Identity> proxyIdentities) { Dictionary<Identity, ObjectPrx> proxyMap = new Dictionary<Identity, ObjectPrx>(); if ((proxyIdentities != null) && (proxyIdentities.Count > 0)) { foreach (Identity identity in proxyIdentities) { if (identity != null) { ObjectPrx proxy = getPeerProxy(peerHostAndPort, identity); if (proxy != null) { proxyMap.Add(identity, proxy); } else { log(" Ignoring null proxy returned for identity [" + Util.identityToString(identity) + "]"); } } else { log("ignoring null identity"); } } } return proxyMap; }
private void disconnectFromPeer(HostAndPort peerHostAndPort, bool willNotifyPeer) { if (peerHostAndPortToProxyMap.ContainsKey(peerHostAndPort)) { if (willNotifyPeer) { notifyPeerOfDisconnection(peerHostAndPort); } peerHostAndPortToProxyMap.Remove(peerHostAndPort); stopAndRemovePinger(peerHostAndPort); } }