Skip to content

Commit

Permalink
try a few new things if may delete tomorrow
Browse files Browse the repository at this point in the history
  • Loading branch information
gaochundong committed Mar 29, 2016
1 parent 18017c8 commit cd7fa6b
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Cowboy/Cowboy.Codec.WebSocket/AsyncWebSocketSession.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cowboy.Sockets;

namespace Cowboy.Codec.WebSocket
{
public sealed class AsyncWebSocketSession : IAsyncTcpSocketServerMessageDispatcher
{
public async Task OnSessionStarted(AsyncTcpSocketSession session)
{
//Console.WriteLine(string.Format("TCP session {0} has connected {1}.", session.RemoteEndPoint, session));
await Task.CompletedTask;
}

public async Task OnSessionDataReceived(AsyncTcpSocketSession session, byte[] data, int offset, int count)
{
var text = Encoding.UTF8.GetString(data, offset, count);
//Console.Write(string.Format("Client : {0} --> ", session.RemoteEndPoint));
//Console.WriteLine(text);

await session.SendAsync(Encoding.UTF8.GetBytes(text));
}

public async Task OnSessionClosed(AsyncTcpSocketSession session)
{
//Console.WriteLine(string.Format("TCP session {0} has disconnected.", session));
await Task.CompletedTask;
}
}
}
63 changes: 63 additions & 0 deletions Cowboy/Cowboy.Codec.WebSocket/Cowboy.Codec.WebSocket.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1207366D-F9E6-4D92-A25C-BEC8220434C0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Cowboy.Codec.WebSocket</RootNamespace>
<AssemblyName>Cowboy.Codec.WebSocket</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\SolutionVersion.cs">
<Link>SolutionVersion.cs</Link>
</Compile>
<Compile Include="AsyncWebSocketSession.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Cowboy.Buffer\Cowboy.Buffer.csproj">
<Project>{11ae03d6-db99-436b-950a-2ebcef1c82c5}</Project>
<Name>Cowboy.Buffer</Name>
</ProjectReference>
<ProjectReference Include="..\Cowboy.Sockets\Cowboy.Sockets.csproj">
<Project>{39d916fe-2c09-47ab-a5a2-1a23787f20ba}</Project>
<Name>Cowboy.Sockets</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
5 changes: 5 additions & 0 deletions Cowboy/Cowboy.Codec.WebSocket/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("Cowboy.Codec.WebSocket")]
[assembly: Guid("1207366d-f9e6-4d92-a25c-bec8220434c0")]
6 changes: 6 additions & 0 deletions Cowboy/Cowboy.sln
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Codec", "Codec", "{CC4F673F
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cowboy.Codec.Mqtt.TestMqttClient", "Tests\Cowboy.Codec.Mqtt.TestMqttClient\Cowboy.Codec.Mqtt.TestMqttClient.csproj", "{336F771B-FBEE-4804-9690-8EBC422E4B11}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cowboy.Codec.WebSocket", "Cowboy.Codec.WebSocket\Cowboy.Codec.WebSocket.csproj", "{1207366D-F9E6-4D92-A25C-BEC8220434C0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -150,6 +152,10 @@ Global
{336F771B-FBEE-4804-9690-8EBC422E4B11}.Debug|Any CPU.Build.0 = Debug|Any CPU
{336F771B-FBEE-4804-9690-8EBC422E4B11}.Release|Any CPU.ActiveCfg = Release|Any CPU
{336F771B-FBEE-4804-9690-8EBC422E4B11}.Release|Any CPU.Build.0 = Release|Any CPU
{1207366D-F9E6-4D92-A25C-BEC8220434C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1207366D-F9E6-4D92-A25C-BEC8220434C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1207366D-F9E6-4D92-A25C-BEC8220434C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1207366D-F9E6-4D92-A25C-BEC8220434C0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit cd7fa6b

Please sign in to comment.