예제 #1
0
 public MessageAsyncResult(object caller, Message request, AsyncCallback callback, object state) {
     _caller = caller;
     _request = request;
     _asyncCallback = callback;
     _asyncState = state;
     Trace.TraceInformation("MessageAsyncResult#" + ValidationHelper.HashString(this) + "::.ctor()");
 }
예제 #2
0
        public void Serialize(Stream stream, Message message) {
            Debug.Assert(message.Identity.SubCommand == SubCommand.Response ||
                message.Identity.SubCommand == SubCommand.Request, "Message send to the CAPI from application can be request or response.");
            BinaryWriter writer = new BinaryWriter(stream, Encoding.ASCII);

            MessageHeader header = new MessageHeader();
            header.Command = message.Identity.Command;
            header.SubCommand = message.Identity.SubCommand;
            header.AppID = (short)_application.AppID;
            header.ID = message.Number;

            ((ICapiSerializable)header).Write(writer);
            ((ICapiSerializable)message).Write(writer);

            header.TotalLength = (Int16)stream.Length;

            writer.Seek(0, SeekOrigin.Begin);
            writer.Write(header.TotalLength);
        }
예제 #3
0
 public MessageEventArgs(Message message) {
     _message = message;
 }
예제 #4
0
 public ControllerEventArgs(Message message, Connection connection)
     : base(message)
 {
     _connection = connection;
 }
예제 #5
0
 public void SendMessage(Message message) {
     using (MemoryStream stream = new MemoryStream()) {
         if (message.Identity.SubCommand == SubCommand.Request && message.Number == 0) {
             message.Number = GetUniqueMessageNumber();
         }
         _serializer.Serialize(stream, message);
         CapiPInvoke.PutMessage(_appID, stream);
     }
 }