public override void Dispatch(BaseRequest message, INodeBearer nodeBearer) { var node = nodeBearer.Node; Console.WriteLine($"Got message LightModel - Nodeid = {node.Id}"); var status = new BaseRequest() { DST = message.SRC, Procedure = message.Procedure, Heartbeats = node.ConfigurationServerModel.DefaultTTL, MessageType = MessageType.STATUS, SRC = new Address(AddressType.Unicast, (ushort)ElementId) }; switch (message.Procedure) { case Procedure.Light: if (message.MessageType == MessageType.SET) { ON = message.Parameters == 1; } status.Parameters = Convert.ToInt32(ON); break; default: break; } nodeBearer.Send(status); }
public void SendMessage(INodeBearer nodeBearer, BaseRequest message) { message.SRC = new Address(AddressType.Unicast, (ushort)ElementId); message.Heartbeats = nodeBearer.Node.ConfigurationServerModel.DefaultTTL; nodeBearer.Send(message); }
public override void Dispatch(BaseRequest message, INodeBearer nodeBearer) { var node = nodeBearer.Node; Console.WriteLine($"Got message ConfigurationServerModel - Nodeid = {node.Id}"); node.StatusFlag = 2; System.Threading.Thread.Sleep(100); node.StatusFlag = 0; var status = new BaseRequest() { DST = message.SRC, Procedure = message.Procedure, Heartbeats = node.ConfigurationServerModel.DefaultTTL, MessageType = MessageType.STATUS, SRC = new Address(AddressType.Unicast, (ushort)ElementId) }; switch (message.Procedure) { case Procedure.DefaultTTL: if (message.MessageType == MessageType.SET) { DefaultTTL = message.Parameters; } status.Parameters = DefaultTTL; break; case Procedure.GATTProxy: if (message.MessageType == MessageType.SET) { GATTProxy = message.Parameters == 1; } status.Parameters = Convert.ToInt32(GATTProxy); break; case Procedure.Friend: if (message.MessageType == MessageType.SET) { Friend = message.Parameters == 1; } status.Parameters = Convert.ToInt32(Friend); break; case Procedure.Relay: if (message.MessageType == MessageType.SET) { Relay = message.Parameters == 1; } status.Parameters = Convert.ToInt32(Relay); break; case Procedure.SubscriptionList: throw new NotImplementedException(); break; default: throw new ArgumentException($"Procedure not found in ConfigurationServerModel"); } nodeBearer.Send(status); }