/// <summary> /// 执行工作 /// </summary> /// <param name="socket"></param> /// <returns>返回状态,其中-1会导致重连</returns> protected sealed override int DoWork(SubscriberSocket socket) { byte[] buffer; if (!socket.TryReceiveFrameBytes(timeOut, out buffer)) { Thread.Sleep(10); return(0); } try { var reader = new CommandReader(buffer); reader.ReadCommandFromBuffer(); Console.WriteLine("收到消息" + reader.Command.Data.GetType()); Push(reader.Command); } catch (Exception ex) { Trace.WriteLine(ex, GetType().Name + "DoWork"); return(-1); } return(0); }