Exemplo n.º 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()");
 }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 public MessageEventArgs(Message message) {
     _message = message;
 }
Exemplo n.º 4
0
 public ControllerEventArgs(Message message, Connection connection)
     : base(message)
 {
     _connection = connection;
 }
Exemplo n.º 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);
     }
 }