Click here to Skip to main content
15,892,643 members
Articles / Web Development / HTML5

Fun with HTML5 Canvas, WebSocket, JQuery and ASP.NET. End-result: A live white board on a web page!

Rate me:
Please Sign up or sign in to vote.
4.97/5 (92 votes)
28 Jun 2011CPOL15 min read 278.5K   12.6K   242  
Playing with some of the cutting edge stuff to develop a live drawing white board on a web page where multiple people can collaborate and each person has the same view at the same time without any page refresh.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SuperSocket.SocketBase.Config;
using System.Reflection;
using SuperSocket.Common;
using SuperSocket.SocketBase.Command;

namespace SuperWebSocket.SubProtocol
{
    public class BasicSubProtocol : ISubProtocol
    {
        private Assembly m_CommandAssembly;

        public BasicSubProtocol(Assembly commandAssembly)
            : this()
        {
            m_CommandAssembly = commandAssembly;
        }

        public BasicSubProtocol()
        {
            SubCommandParser = new BasicSubCommandParser();
        }

        #region ISubProtocol Members

        public ISubProtocolCommandParser SubCommandParser { get; private set; }

        public IEnumerable<ISubCommand> GetSubCommands()
        {
            if (m_CommandAssembly == null)
                m_CommandAssembly = Assembly.GetEntryAssembly();

            return m_CommandAssembly.GetImplementedObjectsByInterface<ISubCommand>().Cast<ISubCommand>();
        }

        public bool Initialize(IServerConfig config)
        {
            if (m_CommandAssembly != null)
                return true;

            var commandAssembly = config.Parameters.GetValue("commandAssembly");

            if (string.IsNullOrEmpty(commandAssembly))
                return true;

            try
            {
                m_CommandAssembly = Assembly.Load(commandAssembly);
                return true;
            }
            catch (Exception e)
            {
                LogUtil.LogError(e);
                return false;
            }
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder SmartAspects
Bangladesh Bangladesh
I write codes to make life easier, and that pretty much describes me.

Comments and Discussions