void OnEventClose(UdpEvent ev) { if (ChangeState(UdpSocketState.Running, UdpSocketState.Shutdown)) { for (int i = 0; i < connList.Count; ++i) { UdpConnection cn = connList[i]; cn.SendCommand(UdpCommandType.Disconnected); cn.ChangeState(UdpConnectionState.Disconnected); } if (platform.Close() == false) { UdpLog.Error("failed to shutdown socket interface, platform code: {0}", platform.PlatformError.ToString()); } connList.Clear(); connLookup.Clear(); eventQueueIn.Clear(); pendingConnections.Clear(); GetReadStream().Data = null; GetWriteStream(0, 0).Data = null; UdpLog.Error("OnEventClose: {0}", ev.EndPoint.ToString()); } }
void ProcessTimeouts() { if ((frame & 3) == 3) { uint now = GetCurrentTime(); for (int i = 0; i < connList.Count; ++i) { UdpConnection cn = connList[i]; switch (cn.state) { case UdpConnectionState.Connecting: cn.ProcessConnectingTimeouts(now); break; case UdpConnectionState.Connected: cn.ProcessConnectedTimeouts(now); break; case UdpConnectionState.Disconnected: cn.ChangeState(UdpConnectionState.Destroy); break; case UdpConnectionState.Destroy: if (DestroyConnection(cn)) { --i; } break; } } } }
internal void Raise(int eventType, UdpConnection connection) { UdpEvent ev = new UdpEvent(); ev.Type = eventType; ev.Connection = connection; Raise(ev); }
internal void Raise(int eventType, UdpConnection connection, object obj) { UdpEvent ev = new UdpEvent(); ev.Type = eventType; ev.Connection = connection; ev.Object = obj; Raise(ev); }
internal void Raise(int eventType, UdpConnection connection, UdpConnectionOption option, int value) { UdpEvent ev = new UdpEvent(); ev.Type = eventType; ev.Connection = connection; ev.Option = option; ev.OptionIntValue = value; Raise(ev); }
internal void Raise(int eventType, UdpConnection connection, object obj, UdpSendFailReason reason) { UdpEvent ev = new UdpEvent(); ev.Type = eventType; ev.Connection = connection; ev.FailedReason = reason; ev.Object = obj; Raise(ev); }
void OnEventConnect(UdpEvent ev) { if (CheckState(udpSocketState.Running)) { UdpConnection cn = CreateConnection(ev.EndPoint, UdpConnectionMode.Client); if (cn == null) { UdpLog.Error("could not create connection for endpoint {0}", ev.EndPoint.ToString()); } } }
bool DestroyConnect(UdpConnection cn) { for (int i = 0; i < connList.Count; ++i) { if (connList[i] == cn) { connList.RemoveAt(i); return(true); } } return(false); }
UdpConnection CreateConnection(UdpEndPoint endpoint, UdpConnectionMode mode) { if (connLookup.ContainsKey(endpoint)) { UdpLog.Warn("connection for {0} already exists", endpoint); return(default(UdpConnection)); } UdpConnection cn = new UdpConnection(this, mode, endpoint); connLookup.Add(endpoint, cn); connList.Add(cn); return(cn); }
bool DestroyConnection(UdpConnection cn) { for (int i = 0; i < connList.Count; ++i) { if (connList[i] == cn) { connList.RemoveAt(i); connLookup.Remove(cn.RemoteEndPoint); cn.Destroy(); return(true); } } return(false); }
void AcceptConnection(UdpEndPoint ep) { UdpConnection cn = CreateConnection(ep, UdpConnectionMode.Server); cn.ChangeState(UdpConnectionState.Connected); }
void AcceptConnection(UdpEndPoint ep, object replyObj) { UdpConnection cn = CreateConnection(ep, UdpConnectionMode.Server, replyObj); cn.ChangeState(UdpConnectionState.Connected); }
public BoltConnectionEx(UdpKit.UdpConnection c) : base(c) { }