Beispiel #1
0
        public void GetServerMessagesAsync(DateTime timestamp, Action <DataResponse <List <ServerMessageData> >, Exception> callback)
        {
            ServerMessagesRequest request = new ServerMessagesRequest {
                Timestamp = Timestamp.GetTimestamp(timestamp)
            };

            RpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IServerMessageController.ServerMessages), request, callback);
        }
Beispiel #2
0
            public void GetServerMessagesAsync(DateTime timestamp, Action <DataResponse <List <ServerMessageData> >, Exception> callback)
            {
                ServerMessagesRequest request = new ServerMessagesRequest {
                    Timestamp = Timestamp.GetTimestamp(timestamp)
                };

                PostAsync(SControllerName, nameof(IServerMessageController.ServerMessages), null, request, callback);
            }
Beispiel #3
0
        public HttpResponseMessage ServerMessages(ServerMessagesRequest request)
        {
            DataResponse <List <ServerMessageData> > response = ServerMessageController.DoServerMessages(request);
            var httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ByteArrayContent(VirtualRoot.BinarySerializer.Serialize(response))
            };

            httpResponseMessage.Content.Headers.ContentType = WebApiRoot.BinaryContentType;
            return(httpResponseMessage);
        }
Beispiel #4
0
 public DataResponse <List <ServerMessageData> > ServerMessages(ServerMessagesRequest request)
 {
     try {
         DateTime timestamp = NTMiner.Timestamp.FromTimestamp(request.Timestamp + 1);
         var      data      = HostRoot.Instance.ServerMessageSet.GetServerMessages(timestamp);
         return(DataResponse <List <ServerMessageData> > .Ok(data));
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(ResponseBase.ServerError <DataResponse <List <ServerMessageData> > >(e.Message));
     }
 }
Beispiel #5
0
        public void GetServerMessagesAsync(DateTime timestamp, Action <DataResponse <List <ServerMessageData> >, Exception> callback)
        {
            ServerMessagesRequest request = new ServerMessagesRequest {
                Timestamp = Timestamp.GetTimestamp(timestamp)
            };

            RpcRoot.JsonRequestBinaryResponseRpcHelper.PostAsync(
                _controllerName,
                nameof(IServerMessageBinaryController <HttpResponseMessage> .ServerMessages),
                request,
                callback);
        }
 internal static DataResponse <List <ServerMessageData> > DoServerMessages(ServerMessagesRequest request)
 {
     if (request == null ||
         request.Timestamp < 0 /*早于1970年*/ ||
         request.Timestamp > Timestamp.GetTimestamp(DateTime.Now.AddDays(1)) /*晚于明天*/)
     {
         return(ResponseBase.InvalidInput <DataResponse <List <ServerMessageData> > >("参数错误"));
     }
     try {
         DateTime timestamp = Timestamp.FromTimestamp(request.Timestamp + 1);
         var      data      = WebApiRoot.ServerMessageSet.GetServerMessages(timestamp);
         return(DataResponse <List <ServerMessageData> > .Ok(data));
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(ResponseBase.ServerError <DataResponse <List <ServerMessageData> > >(e.Message));
     }
 }
 public DataResponse <List <ServerMessageData> > ServerMessages([FromBody] ServerMessagesRequest request)
 {
     return(DoServerMessages(request));
 }