public void Move(ObjDirection direction) { if (Map.Instance == null || (Map.Instance.Player != null && ID != Map.Instance.Player.ID)) { DoMove(direction); } if (HasStatus(ObjStatus.MOVE) && direction == m_direction) { return; } if (Game.SinglePlayer == 0) { if (DateTime.Now.Ticks - m_lastMoveProto > 200 * 10000) { m_lastMoveProto = DateTime.Now.Ticks; Net.m_obj_move_tos t1 = new Net.m_obj_move_tos(); t1.Direction = (int)direction; WSocket.Send(t1); } } else { m_nextdirection = direction; } }
public void StopMove() { if (!HasStatus(ObjStatus.MOVE)) { return; } if (Map.Instance == null || ID != Map.Instance.Player.ID) { DoStopMove(); } if (Game.SinglePlayer == 0) { if (DateTime.Now.Ticks - m_lastMoveProto > 200 * 10000) { m_lastMoveProto = DateTime.Now.Ticks; Net.m_obj_move_tos t1 = new Net.m_obj_move_tos(); t1.Direction = (int)(ObjDirection.STOP); WSocket.Send(t1); } } else { m_nextdirection = ObjDirection.STOP; } }
public void Connected() { WSocket socket = new WSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); Assert.IsFalse(socket.Connected); //todo find a way to test if a socket is connected without having to connect to an external device }
public static void ThrHeartbeat() { while (true) { m_heartbeat_tos tos = new m_heartbeat_tos(); WSocket.Send(tos); Thread.Sleep(1000); } }
public static void BtnLogin() { string account = Inputmgr.GetCache("account"); string pwd = Inputmgr.GetCache("pwd"); m_login_tos t1 = new m_login_tos(); t1.Name = account; t1.Pwd = MD5Helper.Md5(pwd); t1.Op = (int)STATUS.LOGIN; WSocket.Send(t1); }
public void GetterSetterTest() { CameraSocket testCameraSocket = new CameraSocket(); #region socket Assert.IsNull(testCameraSocket.DataSocket); WSocket testSocket = new WSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); testCameraSocket.DataSocket = testSocket; Assert.IsTrue(testCameraSocket.DataSocket != null); Assert.IsTrue(testCameraSocket.DataSocket.Equals(testSocket)); ISocket testSocketget = testCameraSocket.DataSocket; Assert.IsTrue(testSocket.Equals(testSocketget)); #endregion #region config CameraConfiguration camConfigTest = new CameraConfiguration { Id = 233, CamFileIdentity = "superTest string" }; Assert.IsNull(testCameraSocket.Config); testCameraSocket.Config = camConfigTest; Assert.IsTrue(testCameraSocket.Config.Id == 233); Assert.IsTrue(testCameraSocket.Config.CamFileIdentity == "superTest string"); #endregion }
public override AsyncReply <bool> Execute(HTTPConnection sender) { if (sender.IsWebsocketRequest()) { if (Server == null) { return(new AsyncReply <bool>(false)); } var tcpSocket = sender.Unassign(); if (tcpSocket == null) { return(new AsyncReply <bool>(false)); } var httpServer = sender.Parent; var wsSocket = new WSocket(tcpSocket); httpServer.Remove(sender); var iipConnection = new DistributedConnection(); Server.Add(iipConnection); iipConnection.Assign(wsSocket); wsSocket.Begin(); return(new AsyncReply <bool>(true)); } return(new AsyncReply <bool>(false)); /* * if (sender.Request.Filename.StartsWith("/iip/")) * { * // find the service * var path = sender.Request.Filename.Substring(5);// sender.Request.Query["path"]; * * * Warehouse.Get(path).Then((r) => * { * if (r is DistributedServer) * { * var httpServer = sender.Parent; * var iipServer = r as DistributedServer; * var tcpSocket = sender.Unassign(); * if (tcpSocket == null) * return; * * var wsSocket = new WSSocket(tcpSocket); * httpServer.RemoveConnection(sender); * * //httpServer.Connections.Remove(sender); * var iipConnection = new DistributedConnection(); * // iipConnection.OnReady += IipConnection_OnReady; * // iipConnection.Server = iipServer; * // iipConnection.Assign(wsSocket); * * iipServer.AddConnection(iipConnection); * iipConnection.Assign(wsSocket); * wsSocket.Begin(); * } * }); * * return true; * } * * return false; */ }