public void DoClientRegister() { BidderRegisterRequest req = new BidderRegisterRequest(); req.MachineCode = GetMachineCode(); req.ClientVersion = Ver.ver; req.LocalIpAddress = KK.GetLocalIP(); req.SeatNo = GetClientSeatNo(); JsonCommand comm = JsonCommands.OK(CommandDirective.CLIENT_REGISTER, req); RawMessage msg = MessageUtils.BuildJsonMessage(_clientNo, comm); socketClient.Send(msg); logger.InfoFormat("send DoClientRegister tcp request..."); }
private void DoPriceAction(PriceAction action, int screenPrice, int targetPrice, DateTime screenTime, int usedDelayMills, DateTime occurTime, string memo = "") { PriceActionRequest req = new PriceActionRequest(); req.MachineCode = clientService.GetMachineCode(); req.OccurTime = occurTime == null ? DateTime.Now : occurTime; req.ScreenTime = screenTime; req.UsedDelayMills = usedDelayMills; req.Action = action; req.ScreenPrice = screenPrice; req.TargetPrice = targetPrice; JsonCommand comm = JsonCommands.OK(CommandDirective.PRICE_TELL, req.ToLine()); RawMessage msg = MessageUtils.BuildJsonMessage(ClientService.AssignedClientNo, comm); socketClient.Send(msg); logger.InfoFormat("report price#{0}#{1}action#{2} at screenTime#{3} occurTime{4}, usedDelayMills#{5}", screenPrice, targetPrice, action, screenTime, req.OccurTime, usedDelayMills); }
public void Dispatch(RawMessage message, Func <RawMessage, string> dispatchCallback) { IMessageProcessor processor = processors[message.messageType]; if (processor != null) { Task.Factory.StartNew(() => { JsonCommand ret = processor.Handle(message); if (dispatchCallback != null && ret != null && ret.Directive != CommandDirective.NONE) { RawMessage retRaw = MessageUtils.BuildJsonMessage(message.clientNo, ret); string callbackRet = dispatchCallback.Invoke(retRaw); } }); } else { logger.ErrorFormat("no processor for type#{0}, text#{1}.", message.messageType, message.bodyText); } }