void signalHandler(Frame frame) { Channel channel; if (frame.SignalFlag == SignalFlag.Emit) { if (frame.Ptr == 0) { foreach (KeyValuePair<string, Channel> kvp in _channels) { channel = kvp.Value; channel.handleSignal(frame.Clone()); } } else { if (_routes.ContainsKey(frame.Ptr) == false) return; channel = _routes[frame.Ptr]; channel.handleSignal(frame); } } else { if (frame.Ptr == 0) { foreach (KeyValuePair<string, Channel> kvp in _channels) { channel = kvp.Value; deallocChannel(channel, frame.Clone(), null); } } else { if (_routes.ContainsKey(frame.Ptr) == false) return; channel = _routes[frame.Ptr]; if (channel.State != ChannelState.Closing) { // We havent closed our channel yet. We therefor need // to send an ENDSIG in response to this packet. Frame end = Frame.Create(frame.Ptr, SignalFlag.End, ContentType.Utf, null); _adapter.Send(end); } deallocChannel(channel, frame, null); } } }
void dataHandler(Frame frame) { if (frame.Payload == null || frame.Payload.Length == 0) { close("Protocol error: Zero data packet sent received"); return; } Channel channel; if (frame.Ptr == 0) { foreach (KeyValuePair<string, Channel> kvp in _channels) { channel = kvp.Value; if ((channel.Mode & ChannelMode.Read) == ChannelMode.Read) { channel.handleData(frame.Clone()); } } return; } if (_routes.ContainsKey(frame.Ptr) == false) return; channel = _routes[frame.Ptr]; if ((channel.Mode & ChannelMode.Read) == ChannelMode.Read) { channel.handleData(frame); } }