Create a main data message - These are sent by both the client and server anytime the public method Send is called. The expectation is that in most systems that these will be the most frequently sent messages as these are used for application level conversation. All other messages are basically system-management messages. Contains the standard header plus the array of bytes passed in by the application
Exemplo n.º 1
0
 void networkNode_MessageReceived(object sender, MessageEventArgs args)
 {
     log.Append("networkNode_MessageReceived", String.Format("Message Received from {0}", args.SenderID.ToString()));
      TypedMessage message = new TypedMessage(args.Data, args.Data.Length);
      switch (message.type)
      {
     case MessageType.DescriptionRequest:
        log.Append("networkNode_MessageReceived", "Description Request received");
        DescriptionMessage description = new DescriptionMessage(CurrentServerData);
        TypedMessage reply = new TypedMessage(MessageType.DescriptionMessage, description.GetBytes());
        networkNode.SendDirect(reply.GetBytes(), args.SenderID);
        break;
     default:
        break;
      }
 }
Exemplo n.º 2
0
 void client_MessageReceived(object sender, MessageEventArgs a)
 {
     TypedMessage message = new TypedMessage(a.Data, a.Data.Length);
      switch (message.type)
      {
     case MessageType.SensorReadingsData:
        SensorReadingsData data = MessageHelper.DeserializeSensorReadingsData(message.data);
        this.timeOffset = data.Time.Ticks - DateTime.Now.Ticks;
        break;
      }
 }
Exemplo n.º 3
0
 private void SendAliveMessage(object ob)
 {
     TypedMessage message = new TypedMessage(MessageType.AliveMessage, BitConverter.GetBytes((Int64) DateTime.UtcNow.Ticks));
      networkNode.Send(message.GetBytes());
 }