public void Add(AsyncSocket tmp_Socket)
 {
     try {
         _socketCol.Add(tmp_Socket.SocketID, tmp_Socket);
         tmp_Socket.SocketDisconnected += SocketDisconnected;
         tmp_Socket.SocketDataArrival  += SocketDataArrival;
     } catch (Exception ex) {
         throw ex;
     }
 }
 private void m_ServerSocket_ConnectionAccept(AsyncSocket tmp_Socket)
 {
     try {
         Add(tmp_Socket);
         if (onConnectionAccept != null)
         {
             onConnectionAccept(tmp_Socket.SocketID);
         }
     } catch (Exception ex) {
         throw ex;
     }
 }
Example #3
0
 /// <summary>
 /// Set socket
 /// </summary>
 /// <param name="socket"></param>
 /// <returns></returns>
 public bool SetSocket(AsyncSocket socket)
 {
     try {
         _socket = socket;
         _socket.CouldNotConnect += _socket_CouldNotConnect;
         _socket.SocketConnected += _socket_SocketConnected;
         _socket.SocketDataArrival += _socket_SocketDataArrival;
         _socket.SocketDisconnected += _socket_SocketDisconnected;
         return true;
     } catch (Exception ex) {
         throw ex;
     }
 }
Example #4
0
 public void Add(AsyncSocket tmp_Socket)
 {
     try {
         _socketCol.Add(tmp_Socket.SocketID, tmp_Socket);
         tmp_Socket.SocketDisconnected += SocketDisconnected;
         tmp_Socket.SocketDataArrival  += SocketDataArrival;
     } catch (Exception ex) {
         if (SocketError != null)
         {
             SocketError(ex);
         }
     }
 }
Example #5
0
 /// <summary>
 /// Entry Point
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="serverIp"></param>
 /// <param name="port"></param>
 public UserSocket(int userId, string description, string serverIp, int port, int connectionId)
 {
     try {
         Model = new ConnectionModel();
         GlobalObjects.UserSockets.StopMonitoringAll(userId);
         Model.Monitoring = false;
         Model.Server = serverIp;
         Model.Port = port;
         Model.UserId = userId;
         Model.Description = description;
         Model.ConnectionId = connectionId;
         Socket = new AsyncSocket();
         Socket.CouldNotConnect += Socket_CouldNotConnect;
         Socket.SocketConnected += Socket_SocketConnected;
         Socket.SocketDataArrival += Socket_SocketDataArrival;
         Socket.SocketDisconnected += Socket_SocketDisconnected;
         Socket.SocketError += Socket_SocketError;
         ConnectionsHelper.Update(Model);
     } catch (Exception ex) {
         if (ProcessError != null) {
             ProcessError(ex, "UserSocket");
         }
     }
 }
 public void Add(AsyncSocket tmp_Socket)
 {
     try {
         _socketCol.Add(tmp_Socket.SocketID, tmp_Socket);
         tmp_Socket.SocketDisconnected += SocketDisconnected;
         tmp_Socket.SocketDataArrival += SocketDataArrival;
     } catch (Exception ex) {
         throw ex;
     }
 }
 private void m_ServerSocket_ConnectionAccept(AsyncSocket tmp_Socket)
 {
     try {
         Add(tmp_Socket);
         if (onConnectionAccept != null) {
             onConnectionAccept(tmp_Socket.SocketID);
         }
     } catch (Exception ex) {
         throw ex;
     }
 }
Example #8
0
 /// <summary>
 /// Connection Accept
 /// </summary>
 /// <param name="tmp_Socket"></param>
 private void _server_ConnectionAccept(AsyncSocket tmp_Socket)
 {
     try {
         var user = new UserObject();
         _users.Add(user);
         user.SetSocket(tmp_Socket);
     } catch (Exception ex) {
         if (ProcessError != null) {
             ProcessError(ex, "_server_ConnectionAccept");
         }
     }
 }
Example #9
0
 private void _server_ConnectionAccept(AsyncSocket tmp_Socket)
 {
     try {
         var guid = AddUser();
         if (!string.IsNullOrEmpty(guid)) {
             SetSocket(guid, tmp_Socket);
         }
     } catch (Exception ex) {
         throw ex;
     }
 }
Example #10
0
 public bool SetSocket(string guid, AsyncSocket socket)
 {
     if (_users.Where(u => u.GuidStr == guid).Count() != 0) {
         var user = _users.Where(u => u.GuidStr == guid).FirstOrDefault();
         user.SetSocket(socket);
         return true;
     } else {
         return false;
     }
 }
Example #11
0
 /// <summary>
 /// Set socket
 /// </summary>
 /// <param name="socket"></param>
 /// <returns></returns>
 public bool SetSocket(AsyncSocket socket)
 {
     try {
         _socket = socket;
         _socket.CouldNotConnect += _socket_CouldNotConnect;
         _socket.SocketConnected += _socket_SocketConnected;
         _socket.SocketDataArrival += _socket_SocketDataArrival;
         _socket.SocketDisconnected += _socket_SocketDisconnected;
         _socket.SocketError += _socket_SocketError;
         UserModel = new Models.UserModel();
         return true;
     } catch (Exception ex) {
         if (ProcessError != null) {
             ProcessError(ex, "SetSocket");
         }
         return false;
     }
 }
Example #12
0
 /// <summary>
 /// Socket Error
 /// </summary>
 /// <param name="_ex"></param>
 private void Socket_SocketError(Exception _ex)
 {
     try {
         var b = false;
         if (_ex.Message.Contains("An established connection was aborted by the software in your host machine")) {
             b = true;
         } else if (_ex.Message.Contains("An existing connection was forcibly closed by the remote host")) {
             b = true;
         }
         if (b) {
             SocketDisconnected();
         } else {
             Model.Connected = false;
             Socket = new AsyncSocket();
             Socket.CouldNotConnect += Socket_CouldNotConnect;
             Socket.SocketConnected += Socket_SocketConnected;
             Socket.SocketDataArrival += Socket_SocketDataArrival;
             Socket.SocketDisconnected += Socket_SocketDisconnected;
             Socket.SocketError += Socket_SocketError;
             ConnectionsHelper.Update(Model);
         }
     } catch (Exception ex) {
         if (ProcessError != null) {
             ProcessError(ex, "Socket_SocketError");
         }
     }
 }
Example #13
0
 /// <summary>
 /// Could not connect
 /// </summary>
 /// <param name="SocketID"></param>
 private void Socket_CouldNotConnect(string SocketID)
 {
     try {
         if (Model.Monitoring) {
             GlobalObjects.Users.SendSocket(Model.UserId, Model.Server + ":Socket_CouldNotConnect");
         }
         Socket = new AsyncSocket();
         Socket.CouldNotConnect += Socket_CouldNotConnect;
         Socket.SocketConnected += Socket_SocketConnected;
         Socket.SocketDataArrival += Socket_SocketDataArrival;
         Socket.SocketDisconnected += Socket_SocketDisconnected;
         Socket.SocketError += Socket_SocketError;
         Model.Connected = false;
         ConnectionsHelper.Update(Model);
     } catch (Exception ex) {
         if (ProcessError != null) {
             ProcessError(ex, "Socket_CouldNotConnect");
         }
     }
 }
Example #14
0
 /// <summary>
 /// Disconnect
 /// </summary>
 public void Disconnect()
 {
     try {
         Socket.Close();
         Socket = new AsyncSocket();
         Socket.CouldNotConnect += Socket_CouldNotConnect;
         Socket.SocketConnected += Socket_SocketConnected;
         Socket.SocketDataArrival += Socket_SocketDataArrival;
         Socket.SocketDisconnected += Socket_SocketDisconnected;
         Socket.SocketError += Socket_SocketError;
         ConnectionsHelper.Update(Model);
     } catch (Exception ex) {
         if (ProcessError != null) {
             ProcessError(ex, "Disconnect");
         }
     }
 }
Example #15
0
 private void ResetSocket()
 {
     this.UIThread(() => cmdConnect.Text = "Connect");
     this.UIThread(() => cmdConnect.Enabled = true);
     this.UIThread(() => cmdDestroy.Enabled = false);
     this.UIThread(() => cmdList.Enabled = false);
     this.UIThread(() => cmdMonitor.Enabled = false);
     this.UIThread(() => cmdDisconnect.Enabled = false);
     this.UIThread(() => cmdSend.Enabled = false);
     this.UIThread(() => cmdCreate.Enabled = false);
     this.UIThread(() => cmdClose.Enabled = false);
     this.UIThread(() => cmdAuth.Enabled = false);
     this.UIThread(() => cmdStopMonitoring.Enabled = false);
     this.UIThread(() => cmd_Connect.Enabled = false);
     this.UIThread(() => cmdRegister.Enabled = false);
     this.UIThread(() => cmdEmailVerify.Enabled = false);
     System.Threading.Thread.Sleep(200);
     _socket = new AsyncSocket();
     _socket.CouldNotConnect += _socket_CouldNotConnect;
     _socket.SocketConnected += _socket_SocketConnected;
     _socket.SocketDataArrival += _socket_SocketDataArrival;
     _socket.SocketDisconnected += _socket_SocketDisconnected;
 }
Example #16
0
 private void Form1_Load(object sender, EventArgs e)
 {
     _socket = new AsyncSocket();
     _socket.CouldNotConnect += _socket_CouldNotConnect;
     _socket.SocketConnected += _socket_SocketConnected;
     _socket.SocketDataArrival += _socket_SocketDataArrival;
     _socket.SocketDisconnected += _socket_SocketDisconnected;
     _socket.SocketError += _socket_SocketError;
 }