public virtual void OnConnected(IMessageSink messageSink) { _messageSink = messageSink; // todo: remove (sends "welcome" message for testing) var m = new PostilionMessage(); m.ParseFromBuffer(System.Text.Encoding.ASCII.GetBytes("Hello from server. Test 1234567890")); _messageSink.SendMessageAsync(m); }
public void ProcessMessage(PostilionMessage message) { // todo: add all logic here e.g. handshake, state machine, etc. // todo: does exception here kill the connection? // todo: reply message using SendMessage(new PostilionMessage()) // todo: pass on to derived classes for processing // echo message back for testing _messageSink.SendMessageAsync(message); // todo: await }
public ValueTask SendMessageAsync(PostilionMessage message) { return(_messageSink.SendMessageAsync(message)); }