public override void Connect() { if (m_InConnecting) { throw new Exception("The socket is connecting, cannot connect again!"); } if (Client != null) { throw new Exception("The socket is connected, you neednt' connect again!"); } //If there is a proxy set, connect the proxy server by proxy connector if (Proxy != null) { Proxy.Completed += new EventHandler <ProxyEventArgs>(Proxy_Completed); Proxy.Connect(RemoteEndPoint); m_InConnecting = true; return; } m_InConnecting = true; //WindowsPhone doesn't have this property #if SILVERLIGHT && !WINDOWS_PHONE RemoteEndPoint.ConnectAsync(ClientAccessPolicyProtocol, ProcessConnect, null); #else RemoteEndPoint.ConnectAsync(ProcessConnect, null); #endif }
public override bool Connect() { if (m_InConnecting) { throw new Exception("The socket is connecting, cannot connect again!"); } if (Client != null) { throw new Exception("The socket is connected, you neednt' connect again!"); } //WindowsPhone doesn't have this property #if SILVERLIGHT && !WINDOWS_PHONE m_InConnecting = true; RemoteEndPoint.ConnectAsync(ClientAccessPolicyProtocol, ProcessConnect, null); #else m_RecvingCache = null; m_SafeEvents.Clear(); if (!IsSyncConnect) { m_InConnecting = true; RemoteEndPoint.ConnectAsync(ProcessConnect, null); } else { Socket socket = RemoteEndPoint.ConnectSync(); if (socket == null) { return(false); } SocketAsyncEventArgs e = new SocketAsyncEventArgs(); e.Completed += SocketEventArgsCompleted; Client = socket; OnGetSocket(e); } return(true); #endif }
public override void Connect() { if (m_InConnecting) { throw new Exception("The socket is connecting, cannot connect again!"); } if (Client != null) { throw new Exception("The socket is connected, you neednt' connect again!"); } m_InConnecting = true; //WindowsPhone doesn't have this property #if SILVERLIGHT && !WINDOWS_PHONE RemoteEndPoint.ConnectAsync(ClientAccessPolicyProtocol, ProcessConnect, null); #else RemoteEndPoint.ConnectAsync(ProcessConnect, null); #endif }
public override void Connect() { if (m_InConnecting) { throw new Exception("The socket is connecting, cannot connect again!"); } if (Client != null) { throw new Exception("The socket is connected, you neednt' connect again!"); } //If there is a proxy set, connect the proxy server by proxy connector m_InConnecting = true; //WindowsPhone doesn't have this property #if SILVERLIGHT && !WINDOWS_PHONE RemoteEndPoint.ConnectAsync(ClientAccessPolicyProtocol, ProcessConnect, null); #else //采用Begin-End模式实现 RemoteEndPoint.MyConnectAsync(MyProcessConnect, null); #endif }