internal static void Dispatch(NonBlockingConnection conn, ActionBean bean, Protocol protocol) { int priority = 1; Task task = new Task(priority, bean, conn, protocol); ThreadPool.AddTask(task); }
public void _userLogin_1001(UserLoginParams param, NonBlockingConnection conn) { //TODO Your Code Here ConsoleEx.DebugLog(string.Format("The UserName is {0}", param.userName)); ConsoleEx.DebugLog(string.Format("The Password is {0}", param.passwd)); ConsoleEx.DebugLog(string.Format("The Firends size is {0}", param.firends.Count)); }
public bool OnConnect(NonBlockingConnection conn) { ConsoleEx.DebugLog("Connect to the Server."); curConnectType = isConnectType.isConnected; HandleTask(); return(true); }
private Task(int priority, ActionBean bean, NonBlockingConnection conn, Protocol protocol) : base(priority) { this.bean = bean; this.conn = conn; this.protocol = protocol; time_start = WatchDog.GetTime(); }
public void DispatchAct(Protocol protocol, NonBlockingConnection conn) { ActionBean bean = null; if (actions.TryGetValue(protocol.act, out bean)) { // 分配一个线程执行 Task.Dispatch(conn, bean, protocol); } }
public void OnLogin(object ServerEndPoint) { endPoint = ServerEndPoint as DnsEndPoint; Conn = new NonBlockingConnection(endPoint.Host, endPoint.Port, this); if (curConnectType == isConnectType.isConnecting) { curConnectType = isConnectType.isDisconnect; } }
public void sendTcpRequest() { DataHandler handler = new DataHandler(); NonBlockingConnection conn = new NonBlockingConnection("192.168.1.55", 8001, handler); System.Threading.Thread.Sleep(1000); for (int i = 0; i < 10; i++) { conn.Write("madongfang\r\n"); } }
// 接收数据 public bool OnData(NonBlockingConnection conn) { ConsoleEx.DebugLog("Receive data from the server !!"); IList <string> json = conn.ReadStrings(); ConsoleEx.DebugLog("The list size is " + json.Count); foreach (string s in json) { ConsoleEx.DebugLog(s + "=========="); } return(true); }
public bool OnData(NonBlockingConnection conn) { IList <string> json = conn.ReadStrings(); if ((json == null) || (json.Count == 0)) { return(true); } foreach (string s in json) { ActProtocol p = JSON.Instance.ToObject <ActProtocol>(s); Dispatch.Instance.DispatchAct(p, conn); } return(true); }
public void invoke(Protocol proto, NonBlockingConnection conn) { if (proto.act != this.actId) { return; } if (proto.data == null) { return; } ConsoleEx.DebugLog("Receive Protocol :: " + proto.ToString()); IFuncParam newParam = getParamObje(proto.data); try{ mi.Invoke(action, new Object[] { newParam, conn }); } catch (Exception e) { ConsoleEx.DebugLog(e.ToString()); } }
public bool OnData(NonBlockingConnection conn) { IList <string> json = conn.ReadStrings(); if ((json == null) || (json.Count == 0)) { return(true); } foreach (string s in json) { string acknowledge = s.Trim(); int Act = getAct(acknowledge); SocketTask task = null; if (TaskQueue.TryGetValue(Act, out task)) { if (task.respType == TaskResponse.Default_Response || task.respType == TaskResponse.Donot_Send) { if (Utils.checkJsonFormat(acknowledge)) { SocketResponseFactory.createResponse(task, acknowledge); Socket_OnReceive(task); } else { ExceptionResponse exResp = new ExceptionResponse(); exResp.HttpError = acknowledge; task.response = exResp; Socket_OnException(task); } } } else { Socket_CommException(acknowledge); } } return(true); }
public bool OnException(NonBlockingConnection conn, Exception e) { Socket_CommException(e.ToString()); curConnectType = isConnectType.isDisconnect; return(true); }
public bool OnDisconnect(NonBlockingConnection conn) { Socket_CommException("Disconnect from the Server."); curConnectType = isConnectType.isDisconnect; return(true); }
public bool OnConnect(NonBlockingConnection conn) { ConsoleEx.DebugLog("Collect to the Server java "); return(true); }
// 断开连接 public bool OnDisconnect(NonBlockingConnection conn) { ConsoleEx.DebugLog("DisConnect from the server !!"); return(true); }
// 发生异常 public bool OnException(NonBlockingConnection conn, Exception e) { ConsoleEx.DebugLog("Exception occur, the exception is " + e.ToString()); return(true); }
private Task(int priority, ActionBean bean, NonBlockingConnection conn, Protocol protocol) : base(priority) { this.bean = bean; this.conn = conn; this.protocol = protocol; }
// 创建连接 public bool OnConnect (NonBlockingConnection conn) { ConsoleEx.DebugLog("Connect to the server in test!"); return(false); }
public bool OnException(NonBlockingConnection conn, Exception e) { ConsoleEx.DebugLog("Exception happen exception :: " + e.ToString()); return(true); }