This project has moved and is read-only. For the latest updates, please go here.

[en] Which example to experiment with? (solved)

Topics: Technical Support
Jan 18, 2013 at 10:49 AM

Hi guys, I've just started to experiment with Zyan to replace my old .NET Remoting code so I can get comms working from behind NAT etc.

The ultimate aim is to pass messages to and from a server running on an Amazon EC2 instance (I have the base MiniChat working OK on EC2 now).

So, I want to establish a connection using TcpDuplexClientProtocolSetup (and server) and then have this connection capable of firing messages back and forth at any time (not just in a request/response scenario). The server would be started first and wait for inbound messages. It would do things as instructed by the message, then later send a message back on the link to indicate that it had completed.

Which example code would you suggest I work with, that would be most similar to what I need? MiniChat?

Many thanks,

Jan 18, 2013 at 12:20 PM

Hi Dave,

the solution you are search for can be accomplished by using one of the following techniques:

  • Distributed Events (MiniChat uses Distributed Events to notify all Chat Clients on new posts)
  • Serverside registration of Client Callbacks (Clients register callback methods, which are asynchronously called on serverside)

It depends on your needs, which technique fits better.

Events are simpler, but give you less control.
Manual management of Callbacks gives you more control, but you have to write some infrastructure code for maintaining subscriptions.

MiniChat ist the most used example for experiments.

Feel free to ask us, if you need more detailed support.

Best Regards,



Jan 18, 2013 at 12:36 PM

Thanks for the info Rainbird.

I think registration of client callbacks sounds best, as you say - and it is probably most similar to what I was using before - so I'll progress in that direction.

If I get stuck I'll be in touch!

Cheers for now,


Jan 21, 2013 at 4:42 PM

Making some progress now thank you - part of my problem is converting the MiniChat example to VB.NET and also to WinForms rather than console apps.

I found a similar issue to one reported before (discussion 430219 and work item 1852) - where if I start two clients (or a client and a console) - the second one started grabs all the server messages.

I resolved this by setting LegacyBlockingEvents = True on the server because I noticed that if I debugged through the code and upset things by taking a while in the debugger and presumably changing timings, the behaviour changed as well.

Anyway - the real point of my note is this... I need to implement the server-side registration as you suggested to ensure clients only receive messages designated for them. Do you have any sample registration handling code that would get me up and running quicker than me plodding along? I'm not completely useless but C# is not my first language.

P.S. Should I be prefixing my posts with [en] ?


Jan 22, 2013 at 12:17 AM
davegrafton wrote:

P.S. Should I be prefixing my posts with [en] ?

Yes, but I´ve done this for you this time. ;-)

Please have a look at the source code repository. I´ve added a new example project named Zyan.Examples.WhisperChat. This shows conditional notification implemented with callbacks and Zyan.


  • Start the Server
  • Start the Client
  • Type "test1" into the box named Name and then click Register
  • Start another Client
  • Type "test2" into the box named Name and then click Register
  • Type "test1" into the box named Whisper to
  • Type "Hello" into the box named Text
  • Click the Whisper button
  • Now you can see "test2 whispers to you: Hello" inside the chat box on the first client window

I tried to keep the source code as simple as possible.

Feel free to ask me, if you have any questions.