How to run SuperWebSocekt in Standalone way?

Oct 31, 2011 at 8:44 AM

Dear All,

In the existing solution "SuperWebSocket.NET35.sln" I have added a new project "MySuperWebSocket" (as C# Console Application) and added all required references (super web socket and super socket DLLs etc.,)  to my project.

Now I want to write a program to do the below things:

1. To start a SuperWebSocket in a port number 8080.

2. To send / receive messages from my web client.

Please let me know, the class names and API names I have to use to achieve the above two requirements.

And where I have to copy (in which location) my web client files to access my web page using the URL "localhost:8080/mywebpage.html"

Oct 31, 2011 at 8:54 AM

http://superwebsocket.codeplex.com/SourceControl/changeset/view/70641#1322444

Please take a look at the SuperWebSocketService project, it can work as a console application.

 

static void RunAsConsole()
        {
            var serverConfig = ConfigurationManager.GetSection("socketServer") as SocketServiceConfig;
            if (!SocketServerManager.Initialize(serverConfig))
            {
                Console.WriteLine("Failed to initialize SuperSocket server! Please check error log for more information!");
                return;
            }

            if (!SocketServerManager.Start())
            {
                Console.WriteLine("Failed to start SuperWebSocket server! Please check error log for more information!");
                SocketServerManager.Stop();
                return;
            }

            Console.WriteLine("The server has been started! Press key 'q' to stop the server.");

            while (Console.ReadKey().Key != ConsoleKey.Q)
            {
                Console.WriteLine();
                continue;
            }

            SocketServerManager.Stop();

            Console.WriteLine();
            Console.WriteLine("The server has been stopped!");
        }

Oct 31, 2011 at 1:27 PM
Edited Oct 31, 2011 at 2:33 PM

Thank you very much, after I have modified the "App.config" to use .NET version 3.5, it is runing now. 

I have used the batch file "RunServer.bat" but it is aborted with the below error:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies. The system cannot find the file specified.File name: 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821'   at SuperSocket.Common.LogUtil.Setup(String log4netConfig)   at SuperSocket.Common.LogUtil.Setup() in D:\Kerry\Workshop\SuperSocket\v1.4\Common\LogUtil.cs:line 16   at SuperWebSocket.Service.Program.Main(String[] args) in D:\works\smartvis\vs\SuperWebSocket(Drop 8)\SuperWebSocketService\Program.cs:line 20


WRN: Assembly binding logging is turned OFF.To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.Note: There is some performance penalty associated with assembly bind failure logging.To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Additional Info:

This error happens at the file "\SuperWebSocket\WebSocketServer.cs" and at the below function

 

public override bool Setup(IRootConfig rootConfig, IServerConfig config, ISocketServerFactory socketServerFactory, ICustomProtocol protocol)

 

exactly at the statement : 

if (!base.Setup(rootConfig, config, socketServerFactory, protocol))
 

 

Actually the variable "protocol" coming as NULL.

Please help me to resolve this error.

Oct 31, 2011 at 2:54 PM

The error message has told you how to fix it!

You can find the missing file in References folder.

Oct 31, 2011 at 3:14 PM

Thank you very much, It is running now. 

One more help, Where to copy my sample web client files (HTML) ?

SuperWebSocket is running now, but how to find out in which port it is running ?

Oct 31, 2011 at 3:31 PM

It's in configuration file.

Oct 31, 2011 at 3:48 PM

Please let me know in which file it is there?

1. SuperWebSocket.Service.exe.config

2. SuperWebSocket.Service.vshost.exe.config

3. App.config

I think it is in "App.config" file and we can specify in the below XML element am I right?

      <server name="SuperWebSocket" serviceName="SuperWebSocket" ip="Any" port="2011" mode="Async"> </server>

Please let me know how to specify the path of my HTML files?

Oct 31, 2011 at 3:50 PM

Please take a look at the source code of SuperWebSocketWeb or SuperWebSocketWeb.Net35

Nov 3, 2011 at 11:01 AM

I could not able to understand the source code, since I am new to C# and Visual Studio.

Personally I feel, the port configuration and web client files path configuration are basic things, those to be present in some configuration file.

I could not able to process further, please help me.

Nov 3, 2011 at 2:28 PM

I suggest you learn some basic knowledge of .NET developement.

Nov 4, 2011 at 2:43 PM
Edited Nov 4, 2011 at 4:13 PM

Yes, you are right.

We would like to test our web client project with SuperWebSocket. 

That is why I am requesting you to tell the secret of "PORT" and "Client files path" configuration to test SuperWebSocket with our web client.

 Actually ASP.NET it is completely new one for us, we can't study it since we have some other works.

For your information, in Java, PORT configuration for WebSocketServer is very straight forward just we have to pass it as a argument to it's constructor. 

import org.eclipse.jetty.server.Server;

Server server = new Server(PORT_NUMBER);

server.setHandler(hl);

server.start();

Could you please provide such example to start your SuperWebSocket ?