private void WriteRequest(MessageRequestType requestType, IFastBinarySerializable request) { Byte[] bData = null; using (var pool = FastFormatterPool.Pool.Container()) { bData = pool.Instance.Serialize(new MessageHeader(pool.Instance, requestType, request)); } MessageWriter.Write(bData); }
public static T CreateRequest <T>(MessageRequestType type) where T : Req, new() { T request = new T(); ISession session = SessionWeb.Current; request.SessionId = SessionWeb.Current.SessionId; request.CurrentUserLevel = (int)session.UserLevel; //request.MessageLanguage = BasePage.CurrentUserLanguage; return(request); }
private String ReceiveMessage(String msgId) { //check if it exits (not realy needed but demonstrates the usage of the get msg list and it gives us the msg type) GetMessagesListRequestType selectReq = new GetMessagesListRequestType(); selectReq.Source = GetMessagesListRequestTypeSource.INBOX; GetMessageListResponseType listRsp = consult.getMessagesList(selectReq); Assert.AreEqual("100", listRsp.Status.Code); ContentInfoTypeContentType?msgType = null; foreach (GetMessageListResponseTypeMessage msg in listRsp.Message) { if (msg.MessageId == msgId) { msgType = msg.ContentInfo.ContentType; } } Assert.IsNotNull(msgType); //Now that we know it exists and we know if it news or a document we can move on and get it. MessageRequestType fetchReq = new MessageRequestType(); fetchReq.Source = MessageRequestTypeSource.INBOX; fetchReq.MessageId = msgId; GetFullMessageResponseType fetchRsp = consult.getFullMessage(fetchReq); Assert.AreEqual("100", fetchRsp.Status.Code); switch (msgType.Value) { case ContentInfoTypeContentType.NEWS: NewsType news = (NewsType)fetchRsp.Message.ContentContext.Content.Item; return(Encoding.UTF8.GetString(news.Item)); case ContentInfoTypeContentType.DOCUMENT: DocumentType doc = (DocumentType)fetchRsp.Message.ContentContext.Content.Item; return(Encoding.UTF8.GetString(doc.Item)); default: Assert.Fail(); return(null); } }
private String ReceiveMessage(String msgId) { //check if it exits (not realy needed but demonstrates the usage of the get msg list and it gives us the msg type) GetMessagesListRequestType selectReq = new GetMessagesListRequestType(); selectReq.Source = GetMessagesListRequestTypeSource.INBOX; GetMessageListResponseType listRsp = consult.getMessagesList(selectReq); Assert.AreEqual("100", listRsp.Status.Code); ContentInfoTypeContentType? msgType = null; foreach (GetMessageListResponseTypeMessage msg in listRsp.Message) { if (msg.MessageId == msgId) msgType = msg.ContentInfo.ContentType; } Assert.IsNotNull(msgType); //Now that we know it exists and we know if it news or a document we can move on and get it. MessageRequestType fetchReq = new MessageRequestType(); fetchReq.Source = MessageRequestTypeSource.INBOX; fetchReq.MessageId = msgId; GetFullMessageResponseType fetchRsp = consult.getFullMessage(fetchReq); Assert.AreEqual("100", fetchRsp.Status.Code); switch (msgType.Value) { case ContentInfoTypeContentType.NEWS: NewsType news = (NewsType)fetchRsp.Message.ContentContext.Content.Item; return Encoding.UTF8.GetString(news.Item); case ContentInfoTypeContentType.DOCUMENT: DocumentType doc = (DocumentType)fetchRsp.Message.ContentContext.Content.Item; return Encoding.UTF8.GetString(doc.Item); default: Assert.Fail(); return null; } }
} // depending on the request type, this blob can either be a MessageRequest or MessageSequence object public MessageHeader(FastBinaryFormatter ff, MessageRequestType requestType, IFastBinarySerializable request) { RequestType = requestType; Request = new FastSerializerObjectData(ff, request); }