fix WebSocket.cs, WsStream.cs, wsclient.cs
This commit is contained in:
parent
6cd3f2ad91
commit
6b75c09ed2
@ -1,8 +1,8 @@
|
||||
<Properties>
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release_Ubuntu" ctype="Workspace" />
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug_Ubuntu" ctype="Workspace" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="websocket-sharp/WebSocket.cs" ctype="Workbench">
|
||||
<Files>
|
||||
<File FileName="websocket-sharp/WebSocket.cs" Line="231" Column="1" />
|
||||
<File FileName="websocket-sharp/WebSocket.cs" Line="100" Column="1" />
|
||||
</Files>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
|
@ -30,9 +30,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
#if NOTIFY
|
||||
using Notifications;
|
||||
#endif
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -109,13 +106,7 @@ namespace WebSocketSharp
|
||||
private SslStream sslStream;
|
||||
private IWsStream wsStream;
|
||||
private Thread msgThread;
|
||||
#if NOTIFY
|
||||
private Notification msgNf;
|
||||
public Notification MsgNf
|
||||
{
|
||||
get { return msgNf; }
|
||||
}
|
||||
#endif
|
||||
|
||||
public event EventHandler OnOpen;
|
||||
public event MessageEventHandler OnMessage;
|
||||
public event MessageEventHandler OnError;
|
||||
@ -205,11 +196,6 @@ namespace WebSocketSharp
|
||||
|
||||
readyState = state;
|
||||
|
||||
if (OnClose != null)
|
||||
{
|
||||
OnClose(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
if (wsStream != null && tcpClient.Connected)
|
||||
{
|
||||
try
|
||||
@ -228,7 +214,7 @@ namespace WebSocketSharp
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (wsStream != null)
|
||||
{
|
||||
wsStream.Dispose();
|
||||
@ -240,6 +226,14 @@ namespace WebSocketSharp
|
||||
tcpClient.Close();
|
||||
tcpClient = null;
|
||||
}
|
||||
|
||||
if (OnClose != null)
|
||||
{
|
||||
OnClose(this, EventArgs.Empty);
|
||||
}
|
||||
#if DEBUG
|
||||
Console.WriteLine("WS: Info @close: Exit close method.");
|
||||
#endif
|
||||
}
|
||||
|
||||
private void createConnection()
|
||||
@ -355,10 +349,6 @@ namespace WebSocketSharp
|
||||
Console.WriteLine("WS: Info @message: Current thread IsBackground: {0}", Thread.CurrentThread.IsBackground);
|
||||
#endif
|
||||
string data;
|
||||
#if NOTIFY
|
||||
this.msgNf = new Notification();
|
||||
msgNf.AddHint("append", "allowed");
|
||||
#endif
|
||||
while (readyState == WsState.OPEN)
|
||||
{
|
||||
data = receive();
|
||||
@ -435,7 +425,7 @@ namespace WebSocketSharp
|
||||
OnError(this, e.Message);
|
||||
}
|
||||
|
||||
ReadyState = WsState.CLOSING;
|
||||
ReadyState = WsState.CLOSED;
|
||||
#if DEBUG
|
||||
Console.WriteLine("WS: Error @receive: {0}", e.Message);
|
||||
#endif
|
||||
|
@ -42,16 +42,16 @@ namespace WebSocketSharp
|
||||
|
||||
public WsStream(T innerStream)
|
||||
{
|
||||
if (innerStream == null)
|
||||
{
|
||||
throw new ArgumentNullException("innerStream");
|
||||
}
|
||||
|
||||
Type streamType = innerStream.GetType();
|
||||
Type streamType = typeof(T);
|
||||
if (streamType != typeof(NetworkStream) &&
|
||||
streamType != typeof(SslStream))
|
||||
{
|
||||
throw new ArgumentException("Unsupported Stream type: " + streamType.ToString());
|
||||
throw new NotSupportedException("Unsupported Stream type: " + streamType.ToString());
|
||||
}
|
||||
|
||||
if (innerStream == null)
|
||||
{
|
||||
throw new ArgumentNullException("innerStream");
|
||||
}
|
||||
|
||||
this.innerStream = innerStream;
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -34,7 +34,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug_Ubuntu</OutputPath>
|
||||
<DefineConstants>DEBUG,NOTIFY</DefineConstants>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
@ -46,7 +46,6 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<DefineConstants>NOTIFY</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
#if LINUX
|
||||
#if NOTIFY
|
||||
using Notifications;
|
||||
#endif
|
||||
using System;
|
||||
@ -19,36 +19,24 @@ namespace Example
|
||||
//Do something.
|
||||
};
|
||||
*/
|
||||
ws.OnMessage += (o, e) =>
|
||||
ws.OnMessage += (o, s) =>
|
||||
{
|
||||
#if LINUX
|
||||
#if NOTIFY
|
||||
ws.MsgNf.Summary = "[WebSocket] Message";
|
||||
ws.MsgNf.Body = e;
|
||||
ws.MsgNf.IconName = "notification-message-im";
|
||||
ws.MsgNf.Show();
|
||||
#else
|
||||
#if NOTIFY
|
||||
Notification nf = new Notification("[WebSocket] Message",
|
||||
e,
|
||||
s,
|
||||
"notification-message-im");
|
||||
nf.AddHint("append", "allowed");
|
||||
nf.Show();
|
||||
#endif
|
||||
#else
|
||||
Console.WriteLine(e);
|
||||
Console.WriteLine("[WebSocket] Message: {0}", s);
|
||||
#endif
|
||||
};
|
||||
|
||||
ws.OnError += (o, e) =>
|
||||
ws.OnError += (o, s) =>
|
||||
{
|
||||
#if LINUX
|
||||
Notification nf = new Notification("[WebSocket] Error",
|
||||
e,
|
||||
"notification-network-disconnected");
|
||||
nf.Show();
|
||||
#else
|
||||
Console.WriteLine("Error: {0}", e);
|
||||
#endif
|
||||
Console.WriteLine("[WebSocket] Error : {0}", s);
|
||||
};
|
||||
|
||||
/*ws.OnClose += (o, e) =>
|
||||
{
|
||||
//Do something.
|
||||
|
@ -1 +1,68 @@
|
||||
<?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>{52805AEC-EFB1-4F42-BB8E-3ED4E692C568}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>WsClient</RootNamespace>
<AssemblyName>wsclient</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,LINUX,NOTIFY</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>
<DefineConstants>LINUX,NOTIFY</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="notify-sharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=2df29c54e245917a">
<Package>notify-sharp</Package>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="wsclient.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\websocket-sharp\websocket-sharp.csproj">
<Project>{B357BAC7-529E-4D81-A0D2-71041B19C8DE}</Project>
<Name>websocket-sharp</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
|
||||
<?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>{52805AEC-EFB1-4F42-BB8E-3ED4E692C568}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>WsClient</RootNamespace>
|
||||
<AssemblyName>wsclient</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,NOTIFY</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>
|
||||
<DefineConstants>NOTIFY</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="notify-sharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=2df29c54e245917a">
|
||||
<Package>notify-sharp</Package>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="wsclient.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\websocket-sharp\websocket-sharp.csproj">
|
||||
<Project>{B357BAC7-529E-4D81-A0D2-71041B19C8DE}</Project>
|
||||
<Name>websocket-sharp</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user