├── .config
└── dotnet-tools.json
├── .editorconfig
├── .gitignore
├── .husky
├── pre-commit
└── pre-push
├── CHANGELOG.md
├── LICENSE
├── README.md
├── azure-devops
├── check-port.ps1
├── publish.yml
├── templates
│ └── socket.io-tpl.yml
└── test.yml
├── package-lock.json
├── package.json
├── socket.io-client-csharp.sln
├── socket.io-client-csharp.sln.DotSettings
├── src
├── SocketIO.Core
│ ├── EngineIO.cs
│ ├── EngineIOProtocol.cs
│ ├── IMessage.cs
│ ├── MessageType.cs
│ └── SocketIO.Core.csproj
├── SocketIO.Serializer.Core
│ ├── EnumerableExtensions.cs
│ ├── ISerializer.cs
│ ├── SerializedItem.cs
│ └── SocketIO.Serializer.Core.csproj
├── SocketIO.Serializer.MessagePack
│ ├── DictionaryExtensions.cs
│ ├── GenericMessage.cs
│ ├── ObjectDataMessage.cs
│ ├── PackMessage.cs
│ ├── PackMessageOptions.cs
│ ├── PackMessageType.cs
│ ├── SocketIO.Serializer.MessagePack.csproj
│ ├── SocketIOMessagePackSerializer.cs
│ └── TypeExtensions.cs
├── SocketIO.Serializer.NewtonsoftJson
│ ├── ByteArrayConverter.cs
│ ├── JsonMessage.cs
│ ├── NewtonsoftJsonSerializer.cs
│ └── SocketIO.Serializer.NewtonsoftJson.csproj
├── SocketIO.Serializer.SystemTextJson
│ ├── ByteArrayConverter.cs
│ ├── JsonMessage.cs
│ ├── SocketIO.Serializer.SystemTextJson.csproj
│ └── SystemTextJsonSerializer.cs
├── SocketIOClient.Core
│ ├── Messages
│ │ ├── ConnectedMessage.cs
│ │ ├── DisconnectedMessage.cs
│ │ ├── ErrorMessage.cs
│ │ ├── IAckMessage.cs
│ │ ├── IBinaryAckMessage.cs
│ │ ├── IBinaryMessage.cs
│ │ ├── IEventMessage.cs
│ │ ├── IMessage.cs
│ │ ├── INamespaceMessage.cs
│ │ ├── MessageType.cs
│ │ ├── OpenedMessage.cs
│ │ ├── PingMessage.cs
│ │ └── PongMessage.cs
│ ├── ProtocolMessage.cs
│ ├── ProtocolMessageType.cs
│ └── SocketIOClient.Core.csproj
├── SocketIOClient.Serializer.NewtonsoftJson
│ ├── ByteArrayConverter.cs
│ ├── INewtonJsonAckMessage.cs
│ ├── INewtonJsonEventMessage.cs
│ ├── NewtonJsonAckMessage.cs
│ ├── NewtonJsonBinaryAckMessage.cs
│ ├── NewtonJsonBinaryEventMessage.cs
│ ├── NewtonJsonEngineIO3MessageAdapter.cs
│ ├── NewtonJsonEngineIO4MessageAdapter.cs
│ ├── NewtonJsonEventMessage.cs
│ ├── NewtonJsonSerializer.cs
│ └── SocketIOClient.Serializer.NewtonsoftJson.csproj
├── SocketIOClient.Serializer
│ ├── BaseJsonSerializer.cs
│ ├── Decapsulation
│ │ ├── BinaryEventMessageResult.cs
│ │ ├── DecapsulationResult.cs
│ │ ├── Decapsulator.cs
│ │ ├── IDecapsulable.cs
│ │ └── MessageResult.cs
│ ├── IEngineIOMessageAdapter.cs
│ ├── ISerializer.cs
│ ├── SerializationResult.cs
│ └── SocketIOClient.Serializer.csproj
├── SocketIOClient.Windows7
│ ├── ClientWebSocketManaged.cs
│ ├── SocketIOClient.Windows7.csproj
│ └── SocketIOClient.Windows7.snk
└── SocketIOClient
│ ├── DisconnectReason.cs
│ ├── EventHandlers.cs
│ ├── Exceptions
│ └── ConnectionException.cs
│ ├── Extensions
│ ├── CancellationTokenSourceExtensions.cs
│ ├── CancellationTokenSourceWrapper.cs
│ ├── DisposableExtensions.cs
│ ├── EventHandlerExtensions.cs
│ └── SocketIOEventExtensions.cs
│ ├── SocketIO.cs
│ ├── SocketIOClient.csproj
│ ├── SocketIOClient.snk
│ ├── SocketIOOptions.cs
│ ├── SocketIOResponse.cs
│ ├── Transport
│ ├── BaseTransport.cs
│ ├── Http
│ │ ├── DefaultHttpClient.cs
│ │ ├── Eio3HttpPollingHandler.cs
│ │ ├── Eio4HttpPollingHandler.cs
│ │ ├── HttpPollingHandler.cs
│ │ ├── HttpTransport.cs
│ │ ├── IHttpClient.cs
│ │ └── IHttpPollingHandler.cs
│ ├── ITransport.cs
│ ├── TransportException.cs
│ ├── TransportMessageType.cs
│ ├── TransportOptions.cs
│ ├── TransportProtocol.cs
│ └── WebSockets
│ │ ├── ChunkSize.cs
│ │ ├── DefaultClientWebSocket.cs
│ │ ├── IClientWebSocket.cs
│ │ ├── WebSocketReceiveResult.cs
│ │ ├── WebSocketState.cs
│ │ └── WebSocketTransport.cs
│ └── V2
│ ├── Core
│ └── EngineIO.cs
│ ├── DefaultSessionFactory.cs
│ ├── ISocketIO.cs
│ ├── Infrastructure
│ ├── IRandom.cs
│ ├── IRetriable.cs
│ ├── IStopwatch.cs
│ ├── RandomDelayRetryPolicy.cs
│ ├── SystemRandom.cs
│ └── SystemStopwatch.cs
│ ├── Observers
│ ├── IMyObservable.cs
│ └── IMyObserver.cs
│ ├── Protocol
│ ├── Http
│ │ ├── HttpAdapter.cs
│ │ ├── HttpConstants.cs
│ │ ├── HttpRequest.cs
│ │ ├── IHttpAdapter.cs
│ │ ├── IHttpClient.cs
│ │ ├── IHttpRequest.cs
│ │ ├── IHttpResponse.cs
│ │ ├── IHttpResponseObserver.cs
│ │ ├── SystemHttpClient.cs
│ │ └── SystemHttpResponse.cs
│ ├── IProtocolAdapter.cs
│ └── WebSocket
│ │ ├── IWebSocketAdapter.cs
│ │ ├── IWebSocketClient.cs
│ │ └── IWebSocketMessage.cs
│ ├── Serializer
│ └── SystemTextJson
│ │ ├── ByteArrayConverter.cs
│ │ ├── ISystemJsonAckMessage.cs
│ │ ├── ISystemJsonEventMessage.cs
│ │ ├── SystemJsonAckMessage.cs
│ │ ├── SystemJsonBinaryAckMessage.cs
│ │ ├── SystemJsonBinaryEventMessage.cs
│ │ ├── SystemJsonEngineIO3MessageAdapter.cs
│ │ ├── SystemJsonEngineIO4MessageAdapter.cs
│ │ ├── SystemJsonEventMessage.cs
│ │ └── SystemJsonSerializer.cs
│ ├── Session
│ ├── ConnectionFailedException.cs
│ ├── EngineIOHttpAdapter
│ │ ├── EngineIO3Adapter.cs
│ │ ├── EngineIO4Adapter.cs
│ │ └── IEngineIOAdapter.cs
│ ├── HttpSession.cs
│ ├── ISession.cs
│ └── SessionOptions.cs
│ ├── SocketIO.cs
│ ├── SocketIOOptions.cs
│ ├── SocketIOResponse.cs
│ └── UriConverter
│ ├── DefaultUriConverter.cs
│ └── IUriConverter.cs
└── tests
├── SocketIO.Serializer.MessagePack.Tests
├── MessagePackUserDto.cs
├── MessagePackUserPasswordDto.cs
├── SocketIO.Serializer.MessagePack.Tests.csproj
├── SocketIOMessagePackSerializerTests.cs
└── Usings.cs
├── SocketIO.Serializer.NewtonsoftJson.Tests
├── Depth.cs
├── NewtonsoftJsonSerializerTests.cs
├── SocketIO.Serializer.NewtonsoftJson.Tests.csproj
└── Usings.cs
├── SocketIO.Serializer.SystemTextJson.Tests
├── SocketIO.Serializer.SystemTextJson.Tests.csproj
├── SystemTextJsonSerializerTests.cs
└── Usings.cs
├── SocketIO.Serializer.Tests.Models
├── Address.cs
├── FileDto.cs
├── SocketIO.Serializer.Tests.Models.csproj
├── User.cs
└── UserPasswordDto.cs
├── SocketIOClient.IntegrationTests.Net472
├── Properties
│ └── AssemblyInfo.cs
├── SocketIOClient.IntegrationTests.Net472.csproj
├── V4WebSocketTests.cs
├── app.config
└── packages.config
├── SocketIOClient.IntegrationTests
├── AutoReconnectTests.cs
├── MessagePackTests.cs
├── SocketIOClient.IntegrationTests.csproj
├── SocketIOTests.cs
├── SystemTextJsonTests.cs
├── Transport
│ └── WebSockets
│ │ ├── SystemNetWebSocketsClientWebSocketTests.cs
│ │ ├── TestHelper.cs
│ │ ├── WebSocketServer.cs
│ │ └── WebSocketTransportTests.cs
├── Utils
│ └── SerializerHelper.cs
├── V2
│ └── SocketIOTests.cs
├── V2HttpMpNspTests.cs
├── V2HttpMpTests.cs
├── V2HttpStjAuTests.cs
├── V2HttpStjNspAuTests.cs
├── V2HttpStjNspTests.cs
├── V2HttpStjTests.cs
├── V2WsMpNspTests.cs
├── V2WsMpTests.cs
├── V2WsStjNspTests.cs
├── V2WsStjTests.cs
├── V4HttpMpNspTests.cs
├── V4HttpMpTests.cs
├── V4HttpStjAuTests.cs
├── V4HttpStjNspAuTests.cs
├── V4HttpStjNspTests.cs
├── V4HttpStjTests.cs
├── V4WsMpNspTests.cs
├── V4WsMpTests.cs
├── V4WsStjNspTests.cs
└── V4WsStjTests.cs
├── SocketIOClient.Serializer.NewtonsoftJson.Tests
├── NewtonJsonEngineIO3MessageAdapterTests.cs
├── NewtonJsonEngineIO4MessageAdapterTests.cs
├── NewtonJsonSerializerTests.cs
└── SocketIOClient.Serializer.NewtonsoftJson.Tests.csproj
├── SocketIOClient.Serializer.Tests
├── Decapsulation
│ └── DecapsulatorTests.cs
└── SocketIOClient.Serializer.Tests.csproj
├── SocketIOClient.UnitTests
├── ArchUnit
│ └── ArchitectureTests.cs
├── DefaultUriConverterTest.cs
├── SocketIOClient.UnitTests.csproj
└── V2
│ ├── DefaultSessionFactoryTests.cs
│ ├── Infrastructure
│ └── RandomDelayRetryPolicyTests.cs
│ ├── Protocol
│ └── Http
│ │ ├── HttpAdapterTests.cs
│ │ ├── HttpRequestTests.cs
│ │ ├── SystemHttpClientTests.cs
│ │ └── SystemHttpResponseTests.cs
│ ├── Serializer
│ ├── SystemTextJson
│ │ ├── SystemJsonEngineIO3MessageAdapterTests.cs
│ │ ├── SystemJsonEngineIO4MessageAdapterTests.cs
│ │ └── SystemJsonSerializerTests.cs
│ └── TestFile.cs
│ ├── Session
│ ├── EngineIOHttpAdapter
│ │ ├── EngineIO3AdapterTests.cs
│ │ └── EngineIO4AdapterTests.cs
│ └── HttpSessionTests.cs
│ ├── SocketIOOptionsTests.cs
│ └── SocketIOTests.cs
└── socket.io
├── .dockerignore
├── Dockerfile
├── Dockerfile-Test
├── package-lock.json
├── package.json
├── v2
├── index.js
├── package-lock.json
├── package.json
└── template.js
└── v4
├── cert
├── cert.crt
└── private.key
├── index.js
├── package-lock.json
├── package.json
└── template.js
/.config/dotnet-tools.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "isRoot": true,
4 | "tools": {
5 | "dotnet-format": {
6 | "version": "5.1.250801",
7 | "commands": [
8 | "dotnet-format"
9 | ]
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | [*]
2 | trim_trailing_whitespace = true
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | . "$(dirname -- "$0")/_/husky.sh"
3 |
4 | dotnet format --verify-no-changes
--------------------------------------------------------------------------------
/.husky/pre-push:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | . "$(dirname -- "$0")/_/husky.sh"
3 |
4 | dotnet test --no-restore tests/SocketIOClient.UnitTests
5 | dotnet test --no-restore tests/SocketIOClient.Serializer.Tests
6 | dotnet test --no-restore tests/SocketIOClient.Serializer.NewtonsoftJson.Tests
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 HeroWong
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/azure-devops/check-port.ps1:
--------------------------------------------------------------------------------
1 | $ports = 11400, 11401, 11402, 11403, 11404, 11410, 11411, 11412, 11413, 11414, 11200, 11201, 11202, 11203, 11210, 11211, 11212, 11213
2 | $retry = 10
3 | $delay = 3
4 | function Test-SocketIOConnection($Port) {
5 | for ($i = 1; $i -le $retry; $i++) {
6 | $result = Test-Connection -TargetName 127.0.0.1 -TcpPort $Port
7 | if ($result) {
8 | Write-Host "$Port opened"
9 | return $true
10 | }
11 | else {
12 | Write-Host "$Port not open, will retry($i) after $($delay)s ..."
13 | Start-Sleep -Seconds $delay
14 | }
15 | }
16 | Write-Host "$port is not open after $retry retries."
17 | return $false
18 | }
19 |
20 | foreach ($port in $ports) {
21 | $result = Test-SocketIOConnection -Port $port
22 | if (!$result) {
23 | throw "All socket.io server ports must be open, but port $port is closed"
24 | }
25 | }
--------------------------------------------------------------------------------
/azure-devops/publish.yml:
--------------------------------------------------------------------------------
1 | name: Publish ${{ parameters.package }}
2 | trigger: none
3 |
4 | pool:
5 | vmImage: ubuntu-latest
6 |
7 | parameters:
8 | - name: package
9 | displayName: Package
10 | type: string
11 | values:
12 | - SocketIO.Core
13 | - SocketIO.Serializer.Core
14 | - SocketIOClient
15 | - SocketIOClient.Windows7
16 | - SocketIO.Serializer.MessagePack
17 | - SocketIO.Serializer.NewtonsoftJson
18 | - SocketIO.Serializer.SystemTextJson
19 |
20 | jobs:
21 | - job:
22 | displayName: Publish ${{ parameters.package }}
23 | steps:
24 | - pwsh: |
25 | dotnet pack -c Release --output $(Build.ArtifactStagingDirectory)
26 | $packageName = Get-ChildItem $(Build.ArtifactStagingDirectory)/${{ parameters.package }}.*.nupkg | Select-Object -First 1 -ExpandProperty Name
27 | Write-Host "##vso[task.setvariable variable=packageName;]$packageName"
28 | displayName: dotnet pack
29 | workingDirectory: $(System.DefaultWorkingDirectory)/src/${{ parameters.package }}
30 | - pwsh: |
31 | dotnet nuget push $(packageName) -k ${env:NUGET_APIKEY} -s nuget.org
32 | env:
33 | NUGET_APIKEY: $(NUGET_APIKEY)
34 | displayName: Publish ${{ parameters.package }}
35 | workingDirectory: $(Build.ArtifactStagingDirectory)
36 |
--------------------------------------------------------------------------------
/azure-devops/templates/socket.io-tpl.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - pwsh: |
3 | npm install pm2 -g
4 | npm run install-all
5 | pm2 start v2/index.js --name v2/index.js
6 | pm2 start v4/index.js --name v4/index.js
7 | displayName: Run socket.io server
8 | workingDirectory: $(System.DefaultWorkingDirectory)/tests/socket.io
9 | - pwsh: $(System.DefaultWorkingDirectory)/azure-devops/check-port.ps1
10 | displayName: Check ports of socket.io servers
11 | failOnStderr: true
--------------------------------------------------------------------------------
/azure-devops/test.yml:
--------------------------------------------------------------------------------
1 | name: Unit Tests and Integration Tests
2 |
3 | trigger:
4 | - master
5 |
6 | pool:
7 | vmImage: ubuntu-latest
8 |
9 | stages:
10 | - stage: CheckFormat
11 | jobs:
12 | - job:
13 | displayName: Check format
14 | steps:
15 | - script: |
16 | dotnet tool restore
17 | dotnet format --verify-no-changes
18 | displayName: Check format
19 | - stage: NET_Tests
20 | dependsOn: CheckFormat
21 | jobs:
22 | - job:
23 | displayName: Unit tests
24 | steps:
25 | - task: DotNetCoreCLI@2
26 | displayName: SocketIOClient.UnitTests
27 | inputs:
28 | workingDirectory: $(System.DefaultWorkingDirectory)/tests/SocketIOClient.UnitTests
29 | command: test
30 | - task: DotNetCoreCLI@2
31 | displayName: SocketIO.Serializer.SystemTextJson.Tests
32 | inputs:
33 | workingDirectory: $(System.DefaultWorkingDirectory)/tests/SocketIO.Serializer.SystemTextJson.Tests
34 | command: test
35 | - task: DotNetCoreCLI@2
36 | displayName: SocketIO.Serializer.NewtonsoftJson.Tests
37 | inputs:
38 | workingDirectory: $(System.DefaultWorkingDirectory)/tests/SocketIO.Serializer.NewtonsoftJson.Tests
39 | command: test
40 | - task: DotNetCoreCLI@2
41 | displayName: SocketIO.Serializer.MessagePack.Tests
42 | inputs:
43 | workingDirectory: $(System.DefaultWorkingDirectory)/tests/SocketIO.Serializer.MessagePack.Tests
44 | command: test
45 | # - job:
46 | # displayName: Integration tests
47 | # steps:
48 | # - template: templates/socket.io-tpl.yml
49 | # - task: DotNetCoreCLI@2
50 | # displayName: Integration tests
51 | # inputs:
52 | # workingDirectory: $(System.DefaultWorkingDirectory)/tests/SocketIOClient.IntegrationTests
53 | # command: test
54 | # - stage: NET_Framework_Tests
55 | # dependsOn: CheckFormat
56 | # pool:
57 | # vmImage: windows-latest
58 | # jobs:
59 | # - job:
60 | # displayName: Integration tests for .Net Framework
61 | # steps:
62 | # - template: templates/socket.io-tpl.yml
63 | # - pwsh: dotnet restore
64 | # displayName: dotnet restore
65 | # workingDirectory: $(System.DefaultWorkingDirectory)
66 | # - task: MSBuild@1
67 | # inputs:
68 | # solution: $(System.DefaultWorkingDirectory)/socket.io-client-csharp.sln
69 | # restoreNugetPackages: true
70 | # - task: VSTest@2
71 | # inputs:
72 | # testAssemblyVer2: SocketIOClient.IntegrationTests.Net472.dll
73 | # searchFolder: $(System.DefaultWorkingDirectory)/tests/SocketIOClient.IntegrationTests.Net472/bin/Debug
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "socket.io-client-csharp",
3 | "lockfileVersion": 3,
4 | "requires": true,
5 | "packages": {
6 | "": {
7 | "devDependencies": {
8 | "husky": "^9.1.7"
9 | }
10 | },
11 | "node_modules/husky": {
12 | "version": "9.1.7",
13 | "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz",
14 | "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==",
15 | "dev": true,
16 | "bin": {
17 | "husky": "bin.js"
18 | },
19 | "engines": {
20 | "node": ">=18"
21 | },
22 | "funding": {
23 | "url": "https://github.com/sponsors/typicode"
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "devDependencies": {
3 | "husky": "^8.0.0"
4 | },
5 | "scripts": {
6 | "prepare": "husky install"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/socket.io-client-csharp.sln.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | IO
3 | True
4 | True
5 | True
6 | True
--------------------------------------------------------------------------------
/src/SocketIO.Core/EngineIO.cs:
--------------------------------------------------------------------------------
1 | namespace SocketIO.Core
2 | {
3 | public enum EngineIO
4 | {
5 | V3 = 3,
6 | V4 = 4
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/SocketIO.Core/EngineIOProtocol.cs:
--------------------------------------------------------------------------------
1 | namespace SocketIO.Core
2 | {
3 | public enum EngineIOProtocol
4 | {
5 | Open,
6 | Close,
7 | Ping,
8 | Pong,
9 | Message,
10 | Upgrade,
11 | Noop
12 | }
13 | }
--------------------------------------------------------------------------------
/src/SocketIO.Core/IMessage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace SocketIO.Core
5 | {
6 | public interface IMessage
7 | {
8 | MessageType Type { get; }
9 | string Sid { get; set; }
10 | int PingInterval { get; set; }
11 | int PingTimeout { get; set; }
12 | List Upgrades { get; set; }
13 | int BinaryCount { get; set; }
14 | string Namespace { get; set; }
15 | TimeSpan Duration { get; set; }
16 | int Id { get; set; }
17 |
18 | string Event { get; }
19 | string Error { get; set; }
20 |
21 | // TODO: move this to sub class
22 | string ReceivedText { get; set; }
23 | List ReceivedBinary { get; set; }
24 | }
25 | }
--------------------------------------------------------------------------------
/src/SocketIO.Core/MessageType.cs:
--------------------------------------------------------------------------------
1 | namespace SocketIO.Core
2 | {
3 | public enum MessageType
4 | {
5 | Opened,
6 | Ping = 2,
7 | Pong,
8 | Connected = 40,
9 | Disconnected,
10 | Event,
11 | Ack,
12 | Error,
13 | Binary,
14 | BinaryAck,
15 | }
16 | }
--------------------------------------------------------------------------------
/src/SocketIO.Core/SocketIO.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | true
6 | ../SocketIOClient/SocketIOClient.snk
7 | 3.1.2
8 | https://github.com/doghappy/socket.io-client-csharp
9 | doghappy
10 | https://github.com/doghappy/socket.io-client-csharp
11 | github
12 | MIT
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/SocketIO.Serializer.Core/EnumerableExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace SocketIO.Serializer.Core;
5 |
6 | public static class EnumerableExtensions
7 | {
8 | public static bool AnyBinary(this IEnumerable serializedItems)
9 | {
10 | return serializedItems.Any(x => x.Type == SerializedMessageType.Binary);
11 | }
12 |
13 | public static string FirstText(this IEnumerable serializedItems)
14 | {
15 | return serializedItems.First(x => x.Type == SerializedMessageType.Text).Text;
16 | }
17 |
18 | public static List AllBinary(this IEnumerable serializedItems)
19 | {
20 | return serializedItems
21 | .Where(x => x.Type == SerializedMessageType.Binary)
22 | .Select(x => x.Binary)
23 | .ToList();
24 | }
25 | }
--------------------------------------------------------------------------------
/src/SocketIO.Serializer.Core/ISerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using SocketIO.Core;
4 |
5 | namespace SocketIO.Serializer.Core
6 | {
7 | public interface ISerializer
8 | {
9 | // string Serialize(object data);
10 | List Serialize(EngineIO eio, string eventName, int packetId, string ns, object[] data);
11 | List Serialize(EngineIO eio, int packetId, string nsp, object[] data);
12 | List Serialize(EngineIO eio, string eventName, string nsp, object[] data);
13 | T Deserialize(IMessage message, int index);
14 | IMessage Deserialize(EngineIO eio, string text);
15 | IMessage Deserialize(EngineIO eio, byte[] bytes);
16 | string MessageToJson(IMessage message);
17 | IMessage NewMessage(MessageType type);
18 |
19 | SerializedItem SerializeConnectedMessage(EngineIO eio, string ns, object auth, IEnumerable> queries);
20 |
21 | SerializedItem SerializePingMessage();
22 | SerializedItem SerializePongMessage();
23 | SerializedItem SerializeUpgradeMessage();
24 | }
25 | }
--------------------------------------------------------------------------------
/src/SocketIO.Serializer.Core/SerializedItem.cs:
--------------------------------------------------------------------------------
1 | namespace SocketIO.Serializer.Core
2 | {
3 | public class SerializedItem
4 | {
5 | public SerializedMessageType Type { get; set; }
6 | public string Text { get; set; }
7 | public byte[] Binary { get; set; }
8 | }
9 |
10 | public enum SerializedMessageType
11 | {
12 | Text,
13 | Binary,
14 | }
15 | }
--------------------------------------------------------------------------------
/src/SocketIO.Serializer.Core/SocketIO.Serializer.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | default
6 | true
7 | ../SocketIOClient/SocketIOClient.snk
8 | 3.1.2
9 | doghappy
10 | https://github.com/doghappy/socket.io-client-csharp
11 | https://github.com/doghappy/socket.io-client-csharp
12 | github
13 | MIT
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/SocketIO.Serializer.MessagePack/DictionaryExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using MessagePack;
6 |
7 | namespace SocketIO.Serializer.MessagePack;
8 |
9 | static class DictionaryExtensions
10 | {
11 | public static T ToObject(this IDictionary