Thursday, June 21, 2012

ALE - Added A Non-Blocking Web-Sockets Implementation

Continuing Work

Tonight after the kids went to bed I put together a non-blocking Web Sockets implementation. After a lot of trial and error I've finally got it sending and receiving over Web Sockets, at least with Chrome. The changes have been pushed to github. As of this post that would be version v0.0.3.0 ... still very alpha. I'm trying to get the method signatures to be something that flows well for what this architecture does. It's sort of a hard thing to do, IMO. Here's what I've come up with for Web Sockets in ALE, it's loosely based on what Node.js does:

EventLoop.Start(() => {
   Net.CreateServer((socket) => {
      socket.Send("Wee! sockets!");
      socket.Recieve((text) => {
          //do something here.

I think I would like to get the Listen method's signature down to just two parameters that are both string representations of URIs, rather than 3 seperate arguments. I'm also not sure I'm good with how I've implemented the Receive method, which is a little abnormal in the C# world. What it's doing is actually "binding" to an "event", which is really just putting an Action in a List<Action> to be queued to the EventLoop when something is received.

I probably should go back in and clean up the code quite a bit, add comments etc. I've been sprinting so fast and hard whipping this architecture up that I haven't been very diligent with code cleanup or Unit Tests. Mostly just functional testing at this point.

Well... bed time for now...

No comments:

Post a Comment

This form allows some basic HTML. It will only create links if you wrap the URL in an anchor tag (Sorry, it's the Blogger default)