Added WebSocketServer
This commit is contained in:
6
Example2/App.config
Normal file
6
Example2/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="ServerCertPath" value="/path/to/server.cer" />
|
||||
</appSettings>
|
||||
</configuration>
|
27
Example2/AssemblyInfo.cs
Normal file
27
Example2/AssemblyInfo.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("Example2")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("sta")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
|
67
Example2/Example2.csproj
Normal file
67
Example2/Example2.csproj
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{B81A24C8-25BB-42B2-AF99-1E1EACCE74C7}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Example2</RootNamespace>
|
||||
<AssemblyName>example2</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_Ubuntu|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug_Ubuntu</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_Ubuntu|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Release_Ubuntu</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\websocket-sharp\websocket-sharp.csproj">
|
||||
<Project>{B357BAC7-529E-4D81-A0D2-71041B19C8DE}</Project>
|
||||
<Name>websocket-sharp</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
</Project>
|
BIN
Example2/Example2.pidb
Normal file
BIN
Example2/Example2.pidb
Normal file
Binary file not shown.
36
Example2/Program.cs
Normal file
36
Example2/Program.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using WebSocketSharp;
|
||||
|
||||
namespace Example
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
//WebSocketServer wssv = new WebSocketServer("ws://localhost");
|
||||
WebSocketServer wssv = new WebSocketServer("ws://localhost:4649");
|
||||
|
||||
wssv.OnConnection += (sender, e) =>
|
||||
{
|
||||
WebSocket ws = e.Socket;
|
||||
ws.OnMessage += (sender_, e_) =>
|
||||
{
|
||||
// Echo
|
||||
ws.Send(e_.Data);
|
||||
// Chat
|
||||
//wssv.Send(e_.Data);
|
||||
};
|
||||
};
|
||||
|
||||
wssv.Start();
|
||||
Console.WriteLine(
|
||||
"WebSocket Server ({0}) listening on address: {1} port: {2}\n", wssv.Url, wssv.Address, wssv.Port);
|
||||
|
||||
Console.WriteLine("Press any key to stop server...");
|
||||
Console.ReadLine();
|
||||
|
||||
wssv.Stop();
|
||||
}
|
||||
}
|
||||
}
|
BIN
Example2/bin/Debug/example2.exe
Executable file
BIN
Example2/bin/Debug/example2.exe
Executable file
Binary file not shown.
6
Example2/bin/Debug/example2.exe.config
Normal file
6
Example2/bin/Debug/example2.exe.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="ServerCertPath" value="/path/to/server.cer" />
|
||||
</appSettings>
|
||||
</configuration>
|
BIN
Example2/bin/Debug/example2.exe.mdb
Normal file
BIN
Example2/bin/Debug/example2.exe.mdb
Normal file
Binary file not shown.
BIN
Example2/bin/Debug/websocket-sharp.dll
Executable file
BIN
Example2/bin/Debug/websocket-sharp.dll
Executable file
Binary file not shown.
BIN
Example2/bin/Debug/websocket-sharp.dll.mdb
Normal file
BIN
Example2/bin/Debug/websocket-sharp.dll.mdb
Normal file
Binary file not shown.
BIN
Example2/bin/Debug_Ubuntu/example2.exe
Executable file
BIN
Example2/bin/Debug_Ubuntu/example2.exe
Executable file
Binary file not shown.
6
Example2/bin/Debug_Ubuntu/example2.exe.config
Normal file
6
Example2/bin/Debug_Ubuntu/example2.exe.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="ServerCertPath" value="/path/to/server.cer" />
|
||||
</appSettings>
|
||||
</configuration>
|
BIN
Example2/bin/Debug_Ubuntu/example2.exe.mdb
Normal file
BIN
Example2/bin/Debug_Ubuntu/example2.exe.mdb
Normal file
Binary file not shown.
BIN
Example2/bin/Debug_Ubuntu/websocket-sharp.dll
Executable file
BIN
Example2/bin/Debug_Ubuntu/websocket-sharp.dll
Executable file
Binary file not shown.
BIN
Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb
Normal file
BIN
Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb
Normal file
Binary file not shown.
BIN
Example2/bin/Release/example2.exe
Executable file
BIN
Example2/bin/Release/example2.exe
Executable file
Binary file not shown.
6
Example2/bin/Release/example2.exe.config
Normal file
6
Example2/bin/Release/example2.exe.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="ServerCertPath" value="/path/to/server.cer" />
|
||||
</appSettings>
|
||||
</configuration>
|
BIN
Example2/bin/Release/websocket-sharp.dll
Executable file
BIN
Example2/bin/Release/websocket-sharp.dll
Executable file
Binary file not shown.
BIN
Example2/bin/Release_Ubuntu/example2.exe
Executable file
BIN
Example2/bin/Release_Ubuntu/example2.exe
Executable file
Binary file not shown.
6
Example2/bin/Release_Ubuntu/example2.exe.config
Normal file
6
Example2/bin/Release_Ubuntu/example2.exe.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="ServerCertPath" value="/path/to/server.cer" />
|
||||
</appSettings>
|
||||
</configuration>
|
BIN
Example2/bin/Release_Ubuntu/websocket-sharp.dll
Executable file
BIN
Example2/bin/Release_Ubuntu/websocket-sharp.dll
Executable file
Binary file not shown.
Reference in New Issue
Block a user