nterry / AwesomeSockets

A fast, lightweight, and easy to use socket library for C#.
Other
156 stars 35 forks source link

Few Questions #7

Closed NVentimiglia closed 8 years ago

NVentimiglia commented 8 years ago

Stumbled on this library, looks very minimalist (which is great). I think I have a general Idea how to move forward and integrate this into my applications transport layer. That said, I have a few questions.

ISocketModifier, what is it ?

OnConnect / OnDisconnect events. This does not look implemented. I guess, I will need to implement a simple handshake and a heartbeat myself.

nterry commented 8 years ago

@NVentimiglia

Hey! Sorry for the delay. Its great that you have found a use for my little library.

To answer your questions:

ISocketModifier is an interface that is designed to allow you to provide modifications to an ISocket. See https://github.com/nterry/AwesomeSockets/blob/master/AwesomeSockets/Domain/Sockets/ISocket.cs#L31

Using this, for example, you can call:

AweSock.UdpConnect(12345).withModifier(new MulticastSocketModifier()).withModifier(SomeOtherModifierThatYouImplement())... etc

note that withModifier() returns an ISocket so you can chain modifiers together inline (as seen above)!

For now, I only provide https://github.com/nterry/AwesomeSockets/blob/master/AwesomeSockets/Domain/SocketModifiers/MulticastSocketModifier.cs which converts a UDP ISocket into a multicast socket. You are free to implement the interface and do whatever you want, however...

Just as a note as i'm sure your curiosity will make you wonder.... While you technically can pass in a TCP ISocket to the MulticastSocketModifier, it will throw a SocketException as multicast only works over UDP... If you are unfamiliar with what multicast is, go HERE to get more info ;)

AwesomeSockets is very friendly to inline initialization and operation. You can chain many of the methods together so you don't have to create a new object and set one field at a time which takes a lot of precious space.

As to your second question:

Where are you seeing this? Its been some time since I looked at this code, but I can't seem to find those methods... I'm sure i'm just blind ;)

If memory serves and my intuition is right, those are hooks for you to execute custom code on the corresponding events. My lib is a simple facilitator for easily setting up and communicating over a socket... nothing more.... (The idea is simplicity without any hidden magic or side-effects)

If you have any other questions, feel free to email me directly at nick.i.terry@gmail.com (issues are really for... well... issues (if you find a bug or something feel absolutely free to create an issue however!)

PS: Awesome first name, if i do say so myself. (Spelled the right way too ;) )