├── .gitignore ├── LICENSE ├── SocketIO ├── JSONObject │ ├── Editor.meta │ ├── Editor │ │ ├── JSONChecker.cs │ │ └── JSONChecker.cs.meta │ ├── JSONObject.cs │ ├── JSONObject.cs.meta │ ├── JSONTemplates.cs │ ├── JSONTemplates.cs.meta │ ├── VectorTemplates.cs │ ├── VectorTemplates.cs.meta │ ├── readme.txt │ └── readme.txt.meta ├── Prefabs │ ├── SocketIO.prefab │ └── SocketIO.prefab.meta ├── Scenes │ ├── SocketIOTest.unity │ └── SocketIOTest.unity.meta ├── Scripts │ ├── SocketIO.meta │ ├── SocketIO │ │ ├── Ack.cs │ │ ├── Decoder.cs │ │ ├── Decoder.cs.meta │ │ ├── Encoder.cs │ │ ├── Encoder.cs.meta │ │ ├── EnginePacketType.cs │ │ ├── EnginePacketType.cs.meta │ │ ├── Packet.cs │ │ ├── Packet.cs.meta │ │ ├── Parser.cs │ │ ├── Parser.cs.meta │ │ ├── SocketIOComponent.cs │ │ ├── SocketIOComponent.cs.meta │ │ ├── SocketIOEvent.cs │ │ ├── SocketIOEvent.cs.meta │ │ ├── SocketIOException.cs │ │ ├── SocketIOException.cs.meta │ │ ├── SocketPacketType.cs │ │ └── SocketPacketType.cs.meta │ └── Test │ │ └── TestSocketIO.cs ├── Server │ └── beep.js.zip ├── WebsocketSharp │ ├── AssemblyInfo.cs │ ├── AssemblyInfo.cs.meta │ ├── ByteOrder.cs │ ├── ByteOrder.cs.meta │ ├── CloseEventArgs.cs │ ├── CloseEventArgs.cs.meta │ ├── CloseStatusCode.cs │ ├── CloseStatusCode.cs.meta │ ├── CompressionMethod.cs │ ├── CompressionMethod.cs.meta │ ├── ErrorEventArgs.cs │ ├── ErrorEventArgs.cs.meta │ ├── Ext.cs │ ├── Ext.cs.meta │ ├── Fin.cs │ ├── Fin.cs.meta │ ├── HandshakeBase.cs │ ├── HandshakeBase.cs.meta │ ├── HandshakeRequest.cs │ ├── HandshakeRequest.cs.meta │ ├── HandshakeResponse.cs │ ├── HandshakeResponse.cs.meta │ ├── LogData.cs │ ├── LogData.cs.meta │ ├── LogLevel.cs │ ├── LogLevel.cs.meta │ ├── Logger.cs │ ├── Logger.cs.meta │ ├── Mask.cs │ ├── Mask.cs.meta │ ├── MessageEventArgs.cs │ ├── MessageEventArgs.cs.meta │ ├── Net.meta │ ├── Net │ │ ├── AuthenticationBase.cs │ │ ├── AuthenticationBase.cs.meta │ │ ├── AuthenticationChallenge.cs │ │ ├── AuthenticationChallenge.cs.meta │ │ ├── AuthenticationResponse.cs │ │ ├── AuthenticationResponse.cs.meta │ │ ├── AuthenticationSchemes.cs │ │ ├── AuthenticationSchemes.cs.meta │ │ ├── Chunk.cs │ │ ├── Chunk.cs.meta │ │ ├── ChunkStream.cs │ │ ├── ChunkStream.cs.meta │ │ ├── ChunkedRequestStream.cs │ │ ├── ChunkedRequestStream.cs.meta │ │ ├── Cookie.cs │ │ ├── Cookie.cs.meta │ │ ├── CookieCollection.cs │ │ ├── CookieCollection.cs.meta │ │ ├── CookieException.cs │ │ ├── CookieException.cs.meta │ │ ├── EndPointListener.cs │ │ ├── EndPointListener.cs.meta │ │ ├── EndPointManager.cs │ │ ├── EndPointManager.cs.meta │ │ ├── HttpBasicIdentity.cs │ │ ├── HttpBasicIdentity.cs.meta │ │ ├── HttpConnection.cs │ │ ├── HttpConnection.cs.meta │ │ ├── HttpDigestIdentity.cs │ │ ├── HttpDigestIdentity.cs.meta │ │ ├── HttpHeaderInfo.cs │ │ ├── HttpHeaderInfo.cs.meta │ │ ├── HttpHeaderType.cs │ │ ├── HttpHeaderType.cs.meta │ │ ├── HttpListener.cs │ │ ├── HttpListener.cs.meta │ │ ├── HttpListenerContext.cs │ │ ├── HttpListenerContext.cs.meta │ │ ├── HttpListenerException.cs │ │ ├── HttpListenerException.cs.meta │ │ ├── HttpListenerPrefixCollection.cs │ │ ├── HttpListenerPrefixCollection.cs.meta │ │ ├── HttpListenerRequest.cs │ │ ├── HttpListenerRequest.cs.meta │ │ ├── HttpListenerResponse.cs │ │ ├── HttpListenerResponse.cs.meta │ │ ├── HttpStatusCode.cs │ │ ├── HttpStatusCode.cs.meta │ │ ├── HttpStreamAsyncResult.cs │ │ ├── HttpStreamAsyncResult.cs.meta │ │ ├── HttpUtility.cs │ │ ├── HttpUtility.cs.meta │ │ ├── HttpVersion.cs │ │ ├── HttpVersion.cs.meta │ │ ├── InputChunkState.cs │ │ ├── InputChunkState.cs.meta │ │ ├── InputState.cs │ │ ├── InputState.cs.meta │ │ ├── LineState.cs │ │ ├── LineState.cs.meta │ │ ├── ListenerAsyncResult.cs │ │ ├── ListenerAsyncResult.cs.meta │ │ ├── ListenerPrefix.cs │ │ ├── ListenerPrefix.cs.meta │ │ ├── NetworkCredential.cs │ │ ├── NetworkCredential.cs.meta │ │ ├── QueryStringCollection.cs │ │ ├── QueryStringCollection.cs.meta │ │ ├── ReadBufferState.cs │ │ ├── ReadBufferState.cs.meta │ │ ├── RequestStream.cs │ │ ├── RequestStream.cs.meta │ │ ├── ResponseStream.cs │ │ ├── ResponseStream.cs.meta │ │ ├── Security.meta │ │ ├── Security │ │ │ ├── SslStream.cs │ │ │ └── SslStream.cs.meta │ │ ├── WebHeaderCollection.cs │ │ ├── WebHeaderCollection.cs.meta │ │ ├── WebSockets.meta │ │ └── WebSockets │ │ │ ├── HttpListenerWebSocketContext.cs │ │ │ ├── HttpListenerWebSocketContext.cs.meta │ │ │ ├── TcpListenerWebSocketContext.cs │ │ │ ├── TcpListenerWebSocketContext.cs.meta │ │ │ ├── WebSocketContext.cs │ │ │ └── WebSocketContext.cs.meta │ ├── Opcode.cs │ ├── Opcode.cs.meta │ ├── PayloadData.cs │ ├── PayloadData.cs.meta │ ├── Rsv.cs │ ├── Rsv.cs.meta │ ├── WebSocket.cs │ ├── WebSocket.cs.meta │ ├── WebSocketException.cs │ ├── WebSocketException.cs.meta │ ├── WebSocketFrame.cs │ ├── WebSocketFrame.cs.meta │ ├── WebSocketState.cs │ ├── WebSocketState.cs.meta │ ├── WebSocketStream.cs │ ├── WebSocketStream.cs.meta │ ├── websocket-sharp.csproj │ ├── websocket-sharp.csproj.meta │ ├── websocket-sharp.snk │ └── websocket-sharp.snk.meta └── readme.txt └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | 5 | # Autogenerated VS/MD solution and project files 6 | *.csproj 7 | *.unityproj 8 | *.sln 9 | *.suo 10 | *.user 11 | *.userprefs 12 | *.pidb 13 | *.booproj 14 | *.meta 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Fabio R. Panettieri 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. -------------------------------------------------------------------------------- /SocketIO/JSONObject/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b700d54458b2824c934e039a95c468c 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /SocketIO/JSONObject/Editor/JSONChecker.cs: -------------------------------------------------------------------------------- 1 | //#define PERFTEST //For testing performance of parse/stringify. Turn on editor profiling to see how we're doing 2 | 3 | using UnityEngine; 4 | using UnityEditor; 5 | 6 | public class JSONChecker : EditorWindow { 7 | string JSON = @"{ 8 | ""TestObject"": { 9 | ""SomeText"": ""Blah"", 10 | ""SomeObject"": { 11 | ""SomeNumber"": 42, 12 | ""SomeBool"": true, 13 | ""SomeNull"": null 14 | }, 15 | 16 | ""SomeEmptyObject"": { }, 17 | ""SomeEmptyArray"": [ ], 18 | ""EmbeddedObject"": ""{\""field\"":\""Value with \\\""escaped quotes\\\""\""}"" 19 | } 20 | }"; //dat string literal... 21 | JSONObject j; 22 | [MenuItem("Window/JSONChecker")] 23 | static void Init() { 24 | GetWindow(typeof(JSONChecker)); 25 | } 26 | void OnGUI() { 27 | JSON = EditorGUILayout.TextArea(JSON); 28 | GUI.enabled = !string.IsNullOrEmpty(JSON); 29 | if(GUILayout.Button("Check JSON")) { 30 | #if PERFTEST 31 | Profiler.BeginSample("JSONParse"); 32 | j = JSONObject.Create(JSON); 33 | Profiler.EndSample(); 34 | Profiler.BeginSample("JSONStringify"); 35 | j.ToString(true); 36 | Profiler.EndSample(); 37 | #else 38 | j = JSONObject.Create(JSON); 39 | #endif 40 | Debug.Log(j.ToString(true)); 41 | } 42 | if(j) { 43 | //Debug.Log(System.GC.GetTotalMemory(false) + ""); 44 | if(j.type == JSONObject.Type.NULL) 45 | GUILayout.Label("JSON fail:\n" + j.ToString(true)); 46 | else 47 | GUILayout.Label("JSON success:\n" + j.ToString(true)); 48 | 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /SocketIO/JSONObject/Editor/JSONChecker.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c5a625d29393ed4da8d9150a629fb35 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/JSONObject/JSONObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f71819923b555d14ab64ae2044718de9 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/JSONObject/JSONTemplates.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | /* 6 | * http://www.opensource.org/licenses/lgpl-2.1.php 7 | * JSONTemplates class 8 | * for use with Unity 9 | * Copyright Matt Schoen 2010 10 | */ 11 | 12 | public static partial class JSONTemplates { 13 | static readonly HashSet touched = new HashSet(); 14 | 15 | public static JSONObject TOJSON(object obj) { //For a generic guess 16 | if(touched.Add(obj)) { 17 | JSONObject result = JSONObject.obj; 18 | //Fields 19 | FieldInfo[] fieldinfo = obj.GetType().GetFields(); 20 | foreach(FieldInfo fi in fieldinfo) { 21 | JSONObject val = JSONObject.nullJO; 22 | if(!fi.GetValue(obj).Equals(null)) { 23 | MethodInfo info = typeof(JSONTemplates).GetMethod("From" + fi.FieldType.Name); 24 | if(info != null) { 25 | object[] parms = new object[1]; 26 | parms[0] = fi.GetValue(obj); 27 | val = (JSONObject)info.Invoke(null, parms); 28 | } else if(fi.FieldType == typeof(string)) 29 | val = JSONObject.CreateStringObject(fi.GetValue(obj).ToString()); 30 | else 31 | val = JSONObject.Create(fi.GetValue(obj).ToString()); 32 | } 33 | if(val) { 34 | if(val.type != JSONObject.Type.NULL) 35 | result.AddField(fi.Name, val); 36 | else Debug.LogWarning("Null for this non-null object, property " + fi.Name + " of class " + obj.GetType().Name + ". Object type is " + fi.FieldType.Name); 37 | } 38 | } 39 | //Properties 40 | PropertyInfo[] propertyInfo = obj.GetType().GetProperties(); 41 | foreach(PropertyInfo pi in propertyInfo) { 42 | //This section should mirror part of AssetFactory.AddScripts() 43 | JSONObject val = JSONObject.nullJO; 44 | if(!pi.GetValue(obj, null).Equals(null)) { 45 | MethodInfo info = typeof(JSONTemplates).GetMethod("From" + pi.PropertyType.Name); 46 | if(info != null) { 47 | object[] parms = new object[1]; 48 | parms[0] = pi.GetValue(obj, null); 49 | val = (JSONObject)info.Invoke(null, parms); 50 | } else if(pi.PropertyType == typeof(string)) 51 | val = JSONObject.CreateStringObject(pi.GetValue(obj, null).ToString()); 52 | else 53 | val = JSONObject.Create(pi.GetValue(obj, null).ToString()); 54 | } 55 | if(val) { 56 | if(val.type != JSONObject.Type.NULL) 57 | result.AddField(pi.Name, val); 58 | else Debug.LogWarning("Null for this non-null object, property " + pi.Name + " of class " + obj.GetType().Name + ". Object type is " + pi.PropertyType.Name); 59 | } 60 | } 61 | return result; 62 | } 63 | Debug.LogWarning("trying to save the same data twice"); 64 | return JSONObject.nullJO; 65 | } 66 | } 67 | 68 | /* 69 | * Some helpful code templates for the JSON class 70 | * 71 | * LOOP THROUGH OBJECT 72 | for(int i = 0; i < obj.Count; i++){ 73 | if(obj.keys[i] != null){ 74 | switch((string)obj.keys[i]){ 75 | case "key1": 76 | do stuff with (JSONObject)obj.list[i]; 77 | break; 78 | case "key2": 79 | do stuff with (JSONObject)obj.list[i]; 80 | break; 81 | } 82 | } 83 | } 84 | * 85 | * LOOP THROUGH ARRAY 86 | foreach(JSONObject ob in obj.list) 87 | do stuff with ob; 88 | */ 89 | -------------------------------------------------------------------------------- /SocketIO/JSONObject/JSONTemplates.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e45009f4fac2044ea997acbf31422ec 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/JSONObject/VectorTemplates.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 886fb4d7a67d4ce4bb7f51bcc38e20c1 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/JSONObject/readme.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80b692916bec1664098283aa4425e4d8 3 | TextScriptImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /SocketIO/Prefabs/SocketIO.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &100000 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 400000} 11 | - 114: {fileID: 11400000} 12 | m_Layer: 0 13 | m_Name: SocketIO 14 | m_TagString: Untagged 15 | m_Icon: {fileID: 0} 16 | m_NavMeshLayer: 0 17 | m_StaticEditorFlags: 0 18 | m_IsActive: 1 19 | --- !u!4 &400000 20 | Transform: 21 | m_ObjectHideFlags: 1 22 | m_PrefabParentObject: {fileID: 0} 23 | m_PrefabInternal: {fileID: 100100000} 24 | m_GameObject: {fileID: 100000} 25 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 26 | m_LocalPosition: {x: 0, y: 0, z: 0} 27 | m_LocalScale: {x: 1, y: 1, z: 1} 28 | m_Children: [] 29 | m_Father: {fileID: 0} 30 | m_RootOrder: 0 31 | --- !u!114 &11400000 32 | MonoBehaviour: 33 | m_ObjectHideFlags: 1 34 | m_PrefabParentObject: {fileID: 0} 35 | m_PrefabInternal: {fileID: 100100000} 36 | m_GameObject: {fileID: 100000} 37 | m_Enabled: 1 38 | m_EditorHideFlags: 0 39 | m_Script: {fileID: 11500000, guid: 251dc7db9857fae4e8c9293b45173db2, type: 3} 40 | m_Name: 41 | m_EditorClassIdentifier: 42 | url: ws://localhost:4567/socket.io/?EIO=4&transport=websocket 43 | autoConnect: 1 44 | recconectDelay: 5 45 | --- !u!1001 &100100000 46 | Prefab: 47 | m_ObjectHideFlags: 1 48 | serializedVersion: 2 49 | m_Modification: 50 | m_TransformParent: {fileID: 0} 51 | m_Modifications: [] 52 | m_RemovedComponents: [] 53 | m_ParentPrefab: {fileID: 0} 54 | m_RootGameObject: {fileID: 100000} 55 | m_IsPrefabParent: 1 56 | m_IsExploded: 1 57 | -------------------------------------------------------------------------------- /SocketIO/Prefabs/SocketIO.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b30cc084d923f0645b55bba668610d48 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /SocketIO/Scenes/SocketIOTest.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a47a98e2703862044915968f6ffeb597 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c129397f9647414c98ecb454b6c9b61 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/Ack.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * Ack.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 Fabio Panettieri 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace SocketIO 32 | { 33 | public class Ack 34 | { 35 | public int packetId; 36 | public DateTime time; 37 | 38 | private System.Action action; 39 | 40 | public Ack(int packetId, System.Action action) 41 | { 42 | this.packetId = packetId; 43 | this.time = DateTime.Now; 44 | this.action = action; 45 | } 46 | 47 | public void Invoke(JSONObject ev) 48 | { 49 | action.Invoke(ev); 50 | } 51 | 52 | public override string ToString() 53 | { 54 | return string.Format("[Ack: packetId={0}, time={1}, action={2}]", packetId, time, action); 55 | } 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/Decoder.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * Decoder.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 Fabio Panettieri 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | //#define SOCKET_IO_DEBUG // Uncomment this for debug 30 | using System; 31 | using System.Collections; 32 | using System.Text; 33 | using UnityEngine; 34 | using WebSocketSharp; 35 | 36 | namespace SocketIO 37 | { 38 | public class Decoder 39 | { 40 | public Packet Decode(MessageEventArgs e) 41 | { 42 | try 43 | { 44 | #if SOCKET_IO_DEBUG 45 | Debug.Log("[SocketIO] Decoding: " + e.Data); 46 | #endif 47 | 48 | string data = e.Data; 49 | Packet packet = new Packet(); 50 | int offset = 0; 51 | 52 | // look up packet type 53 | int enginePacketType = int.Parse(data.Substring(offset, 1)); 54 | packet.enginePacketType = (EnginePacketType)enginePacketType; 55 | 56 | if (enginePacketType == (int)EnginePacketType.MESSAGE) { 57 | int socketPacketType = int.Parse(data.Substring(++offset, 1)); 58 | packet.socketPacketType = (SocketPacketType)socketPacketType; 59 | } 60 | 61 | // connect message properly parsed 62 | if (data.Length <= 2) { 63 | #if SOCKET_IO_DEBUG 64 | Debug.Log("[SocketIO] Decoded: " + packet); 65 | #endif 66 | return packet; 67 | } 68 | 69 | // look up namespace (if any) 70 | if ('/' == data [offset + 1]) { 71 | StringBuilder builder = new StringBuilder(); 72 | while (offset < data.Length - 1 && data[++offset] != ',') { 73 | builder.Append(data [offset]); 74 | } 75 | packet.nsp = builder.ToString(); 76 | } else { 77 | packet.nsp = "/"; 78 | } 79 | 80 | // look up id 81 | char next = data [offset + 1]; 82 | if (next != ' ' && char.IsNumber(next)) { 83 | StringBuilder builder = new StringBuilder(); 84 | while (offset < data.Length - 1) { 85 | char c = data [++offset]; 86 | if (char.IsNumber(c)) { 87 | builder.Append(c); 88 | } else { 89 | --offset; 90 | break; 91 | } 92 | } 93 | packet.id = int.Parse(builder.ToString()); 94 | } 95 | 96 | // look up json data 97 | if (++offset < data.Length - 1) { 98 | try { 99 | #if SOCKET_IO_DEBUG 100 | Debug.Log("[SocketIO] Parsing JSON: " + data.Substring(offset)); 101 | #endif 102 | packet.json = new JSONObject(data.Substring(offset)); 103 | } catch (Exception ex) { 104 | Debug.LogException(ex); 105 | } 106 | } 107 | 108 | #if SOCKET_IO_DEBUG 109 | Debug.Log("[SocketIO] Decoded: " + packet); 110 | #endif 111 | 112 | return packet; 113 | 114 | } catch(Exception ex) { 115 | throw new SocketIOException("Packet decoding failed: " + e.Data ,ex); 116 | } 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/Decoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d40dc6c848403d4f80ec33a04ab879b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/Encoder.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * Encoder.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 Fabio Panettieri 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | //#define SOCKET_IO_DEBUG // Uncomment this for debug 30 | using System; 31 | using System.Collections; 32 | using System.Text; 33 | using UnityEngine; 34 | 35 | namespace SocketIO 36 | { 37 | public class Encoder 38 | { 39 | public string Encode(Packet packet) 40 | { 41 | try 42 | { 43 | #if SOCKET_IO_DEBUG 44 | Debug.Log("[SocketIO] Encoding: " + packet.json); 45 | #endif 46 | 47 | StringBuilder builder = new StringBuilder(); 48 | 49 | // first is type 50 | builder.Append((int)packet.enginePacketType); 51 | if(!packet.enginePacketType.Equals(EnginePacketType.MESSAGE)){ 52 | return builder.ToString(); 53 | } 54 | 55 | builder.Append((int)packet.socketPacketType); 56 | 57 | // attachments if we have them 58 | if (packet.socketPacketType == SocketPacketType.BINARY_EVENT || packet.socketPacketType == SocketPacketType.BINARY_ACK) { 59 | builder.Append(packet.attachments); 60 | builder.Append('-'); 61 | } 62 | 63 | // if we have a namespace other than '/' 64 | // we append it followed by a comma ',' 65 | if (!string.IsNullOrEmpty(packet.nsp) && !packet.nsp.Equals("/")) { 66 | builder.Append(packet.nsp); 67 | builder.Append(','); 68 | } 69 | 70 | // immediately followed by the id 71 | if (packet.id > -1) { 72 | builder.Append(packet.id); 73 | } 74 | 75 | if (packet.json != null && !packet.json.ToString().Equals("null")) { 76 | builder.Append(packet.json.ToString()); 77 | } 78 | 79 | #if SOCKET_IO_DEBUG 80 | Debug.Log("[SocketIO] Encoded: " + builder); 81 | #endif 82 | 83 | return builder.ToString(); 84 | 85 | } catch(Exception ex) { 86 | throw new SocketIOException("Packet encoding failed: " + packet ,ex); 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/Encoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 54021c10091aa3442be9ff9f375215dc 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/EnginePacketType.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * EnginePacketType.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 Fabio Panettieri 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | using System; 29 | 30 | /** 31 | * Message types 32 | */ 33 | namespace SocketIO 34 | { 35 | public enum EnginePacketType 36 | { 37 | UNKNOWN = -1, 38 | OPEN = 0, 39 | CLOSE = 1, 40 | PING = 2, 41 | PONG = 3, 42 | MESSAGE = 4, 43 | UPGRADE = 5, 44 | NOOP = 6 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/EnginePacketType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17f5d807de2c9a64ab8c31ec880a462f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/Packet.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * Packet.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 Fabio Panettieri 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | namespace SocketIO 30 | { 31 | public class Packet 32 | { 33 | public EnginePacketType enginePacketType; 34 | public SocketPacketType socketPacketType; 35 | 36 | public int attachments; 37 | public string nsp; 38 | public int id; 39 | public JSONObject json; 40 | 41 | public Packet() : this(EnginePacketType.UNKNOWN, SocketPacketType.UNKNOWN, -1, "/", -1, null) { } 42 | public Packet(EnginePacketType enginePacketType) : this(enginePacketType, SocketPacketType.UNKNOWN, -1, "/", -1, null) { } 43 | 44 | public Packet(EnginePacketType enginePacketType, SocketPacketType socketPacketType, int attachments, string nsp, int id, JSONObject json) 45 | { 46 | this.enginePacketType = enginePacketType; 47 | this.socketPacketType = socketPacketType; 48 | this.attachments = attachments; 49 | this.nsp = nsp; 50 | this.id = id; 51 | this.json = json; 52 | } 53 | 54 | public override string ToString() 55 | { 56 | return string.Format("[Packet: enginePacketType={0}, socketPacketType={1}, attachments={2}, nsp={3}, id={4}, json={5}]", enginePacketType, socketPacketType, attachments, nsp, id, json); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/Packet.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d0e1e7a0c99c2754e8ef89f884d5d26c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/Parser.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * Parser.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 Fabio Panettieri 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | using UnityEngine; 29 | 30 | namespace SocketIO 31 | { 32 | public class Parser 33 | { 34 | public SocketIOEvent Parse(JSONObject json) 35 | { 36 | if (json.Count < 1 || json.Count > 2) { 37 | throw new SocketIOException("Invalid number of parameters received: " + json.Count); 38 | } 39 | 40 | if (json[0].type != JSONObject.Type.STRING) { 41 | throw new SocketIOException("Invalid parameter type. " + json[0].type + " received while expecting " + JSONObject.Type.STRING); 42 | } 43 | 44 | if (json.Count == 1) { 45 | return new SocketIOEvent(json[0].str); 46 | } 47 | 48 | if (json[1].type == JSONObject.Type.OBJECT || json[1].type == JSONObject.Type.STRING) { 49 | return new SocketIOEvent(json[0].str, json[1]); 50 | } else { 51 | throw new SocketIOException("Invalid argument type. " + json[1].type + " received"); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/Parser.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a938d61106c4dc46832086f65d1ea92 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/SocketIOComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 251dc7db9857fae4e8c9293b45173db2 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/SocketIOEvent.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * SocketIOEvent.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 Fabio Panettieri 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | namespace SocketIO 30 | { 31 | public class SocketIOEvent 32 | { 33 | public string name { get; set; } 34 | 35 | public JSONObject data { get; set; } 36 | 37 | public SocketIOEvent(string name) : this(name, null) { } 38 | 39 | public SocketIOEvent(string name, JSONObject data) 40 | { 41 | this.name = name; 42 | this.data = data; 43 | } 44 | 45 | public override string ToString() 46 | { 47 | return string.Format("[SocketIOEvent: name={0}, data={1}]", name, data); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/SocketIOEvent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1318072092ea698488b463bebb2848ac 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/SocketIOException.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * SocketIOException.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 Fabio Panettieri 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | using System; 29 | 30 | namespace SocketIO 31 | { 32 | public class SocketIOException : Exception 33 | { 34 | public SocketIOException(){} 35 | public SocketIOException(string message): base(message){} 36 | public SocketIOException(string message, Exception innerException): base(message, innerException){} 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/SocketIOException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ffadf6cd1bc33f4e9a7ef09236f376a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/SocketPacketType.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * SocketPacketType.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 Fabio Panettieri 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | namespace SocketIO 30 | { 31 | public enum SocketPacketType 32 | { 33 | UNKNOWN = -1, 34 | CONNECT = 0, 35 | DISCONNECT = 1, 36 | EVENT = 2, 37 | ACK = 3, 38 | ERROR = 4, 39 | BINARY_EVENT = 5, 40 | BINARY_ACK = 6, 41 | CONTROL = 7 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /SocketIO/Scripts/SocketIO/SocketPacketType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7cb6f7b77863f804c81896a6883bf506 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/Scripts/Test/TestSocketIO.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * TestSocketIO.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 Fabio Panettieri 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System.Collections; 30 | using UnityEngine; 31 | using SocketIO; 32 | 33 | public class TestSocketIO : MonoBehaviour 34 | { 35 | private SocketIOComponent socket; 36 | 37 | public void Start() 38 | { 39 | GameObject go = GameObject.Find("SocketIO"); 40 | socket = go.GetComponent(); 41 | 42 | socket.On("open", TestOpen); 43 | socket.On("boop", TestBoop); 44 | socket.On("error", TestError); 45 | socket.On("close", TestClose); 46 | 47 | StartCoroutine("BeepBoop"); 48 | } 49 | 50 | private IEnumerator BeepBoop() 51 | { 52 | // wait 1 seconds and continue 53 | yield return new WaitForSeconds(1); 54 | 55 | socket.Emit("beep"); 56 | 57 | // wait 3 seconds and continue 58 | yield return new WaitForSeconds(3); 59 | 60 | socket.Emit("beep"); 61 | 62 | // wait 2 seconds and continue 63 | yield return new WaitForSeconds(2); 64 | 65 | socket.Emit("beep"); 66 | 67 | // wait ONE FRAME and continue 68 | yield return null; 69 | 70 | socket.Emit("beep"); 71 | socket.Emit("beep"); 72 | } 73 | 74 | public void TestOpen(SocketIOEvent e) 75 | { 76 | Debug.Log("[SocketIO] Open received: " + e.name + " " + e.data); 77 | } 78 | 79 | public void TestBoop(SocketIOEvent e) 80 | { 81 | Debug.Log("[SocketIO] Boop received: " + e.name + " " + e.data); 82 | 83 | if (e.data == null) { return; } 84 | 85 | Debug.Log( 86 | "#####################################################" + 87 | "THIS: " + e.data.GetField("this").str + 88 | "#####################################################" 89 | ); 90 | } 91 | 92 | public void TestError(SocketIOEvent e) 93 | { 94 | Debug.Log("[SocketIO] Error received: " + e.name + " " + e.data); 95 | } 96 | 97 | public void TestClose(SocketIOEvent e) 98 | { 99 | Debug.Log("[SocketIO] Close received: " + e.name + " " + e.data); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /SocketIO/Server/beep.js.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpanettieri/unity-socket.io-DEPRECATED/98a1abd2909787c467326f843e3344f448b7b3c9/SocketIO/Server/beep.js.zip -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("websocket-sharp")] 8 | [assembly: AssemblyDescription("A C# implementation of the WebSocket protocol client and server")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("websocket-sharp.dll")] 12 | [assembly: AssemblyCopyright("sta.blockhead")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.2.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/AssemblyInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1521934461328a04e98f127fd326e0be 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/ByteOrder.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * ByteOrder.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace WebSocketSharp 32 | { 33 | /// 34 | /// Contains the values that indicate whether the byte order is a Little-endian or Big-endian. 35 | /// 36 | public enum ByteOrder : byte 37 | { 38 | /// 39 | /// Indicates a Little-endian. 40 | /// 41 | Little, 42 | /// 43 | /// Indicates a Big-endian. 44 | /// 45 | Big 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/ByteOrder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3fcb2fa3f551e6a4ba6dd3f7f3d319a4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/CloseEventArgs.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * CloseEventArgs.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | using System.Text; 31 | 32 | namespace WebSocketSharp 33 | { 34 | /// 35 | /// Contains the event data associated with a event. 36 | /// 37 | /// 38 | /// A event occurs when the WebSocket connection has been closed. 39 | /// If you would like to get the reason for the close, you should access the or 40 | /// property. 41 | /// 42 | public class CloseEventArgs : EventArgs 43 | { 44 | #region Private Fields 45 | 46 | private bool _clean; 47 | private ushort _code; 48 | private string _reason; 49 | 50 | #endregion 51 | 52 | #region Internal Constructors 53 | 54 | internal CloseEventArgs (PayloadData payload) 55 | { 56 | var data = payload.ApplicationData; 57 | var len = data.Length; 58 | _code = len > 1 59 | ? data.SubArray (0, 2).ToUInt16 (ByteOrder.Big) 60 | : (ushort) CloseStatusCode.NoStatusCode; 61 | 62 | _reason = len > 2 63 | ? Encoding.UTF8.GetString (data.SubArray (2, len - 2)) 64 | : String.Empty; 65 | } 66 | 67 | #endregion 68 | 69 | #region Public Properties 70 | 71 | /// 72 | /// Gets the status code for the close. 73 | /// 74 | /// 75 | /// A that represents the status code for the close if any. 76 | /// 77 | public ushort Code { 78 | get { 79 | return _code; 80 | } 81 | } 82 | 83 | /// 84 | /// Gets the reason for the close. 85 | /// 86 | /// 87 | /// A that represents the reason for the close if any. 88 | /// 89 | public string Reason { 90 | get { 91 | return _reason; 92 | } 93 | } 94 | 95 | /// 96 | /// Gets a value indicating whether the WebSocket connection has been closed cleanly. 97 | /// 98 | /// 99 | /// true if the WebSocket connection has been closed cleanly; otherwise, false. 100 | /// 101 | public bool WasClean { 102 | get { 103 | return _clean; 104 | } 105 | 106 | internal set { 107 | _clean = value; 108 | } 109 | } 110 | 111 | #endregion 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/CloseEventArgs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a84cd752ba6c7414babf89c045c59704 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/CloseStatusCode.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * CloseStatusCode.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace WebSocketSharp 32 | { 33 | /// 34 | /// Contains the values of the status code for the WebSocket connection close. 35 | /// 36 | /// 37 | /// 38 | /// The values of the status code are defined in 39 | /// Section 7.4 40 | /// of RFC 6455. 41 | /// 42 | /// 43 | /// "Reserved value" must not be set as a status code in a close control frame 44 | /// by an endpoint. It's designated for use in applications expecting a status 45 | /// code to indicate that the connection was closed due to the system grounds. 46 | /// 47 | /// 48 | public enum CloseStatusCode : ushort 49 | { 50 | /// 51 | /// Equivalent to close status 1000. 52 | /// Indicates a normal close. 53 | /// 54 | Normal = 1000, 55 | /// 56 | /// Equivalent to close status 1001. 57 | /// Indicates that an endpoint is going away. 58 | /// 59 | Away = 1001, 60 | /// 61 | /// Equivalent to close status 1002. 62 | /// Indicates that an endpoint is terminating the connection due to a protocol error. 63 | /// 64 | ProtocolError = 1002, 65 | /// 66 | /// Equivalent to close status 1003. 67 | /// Indicates that an endpoint is terminating the connection because it has received 68 | /// an unacceptable type message. 69 | /// 70 | IncorrectData = 1003, 71 | /// 72 | /// Equivalent to close status 1004. 73 | /// Still undefined. Reserved value. 74 | /// 75 | Undefined = 1004, 76 | /// 77 | /// Equivalent to close status 1005. 78 | /// Indicates that no status code was actually present. Reserved value. 79 | /// 80 | NoStatusCode = 1005, 81 | /// 82 | /// Equivalent to close status 1006. 83 | /// Indicates that the connection was closed abnormally. Reserved value. 84 | /// 85 | Abnormal = 1006, 86 | /// 87 | /// Equivalent to close status 1007. 88 | /// Indicates that an endpoint is terminating the connection because it has received 89 | /// a message that contains a data that isn't consistent with the type of the message. 90 | /// 91 | InconsistentData = 1007, 92 | /// 93 | /// Equivalent to close status 1008. 94 | /// Indicates that an endpoint is terminating the connection because it has received 95 | /// a message that violates its policy. 96 | /// 97 | PolicyViolation = 1008, 98 | /// 99 | /// Equivalent to close status 1009. 100 | /// Indicates that an endpoint is terminating the connection because it has received 101 | /// a message that is too big to process. 102 | /// 103 | TooBig = 1009, 104 | /// 105 | /// Equivalent to close status 1010. 106 | /// Indicates that the client is terminating the connection because it has expected 107 | /// the server to negotiate one or more extension, but the server didn't return them 108 | /// in the handshake response. 109 | /// 110 | IgnoreExtension = 1010, 111 | /// 112 | /// Equivalent to close status 1011. 113 | /// Indicates that the server is terminating the connection because it has encountered 114 | /// an unexpected condition that prevented it from fulfilling the request. 115 | /// 116 | ServerError = 1011, 117 | /// 118 | /// Equivalent to close status 1015. 119 | /// Indicates that the connection was closed due to a failure to perform a TLS handshake. 120 | /// Reserved value. 121 | /// 122 | TlsHandshakeFailure = 1015 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/CloseStatusCode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22af06d118f46d441bca7d17c4fdbc41 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/CompressionMethod.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * CompressionMethod.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2013-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace WebSocketSharp 32 | { 33 | /// 34 | /// Contains the values of the compression method used to compress the message on the WebSocket 35 | /// connection. 36 | /// 37 | /// 38 | /// The values of the compression method are defined in 39 | /// Compression 40 | /// Extensions for WebSocket. 41 | /// 42 | public enum CompressionMethod : byte 43 | { 44 | /// 45 | /// Indicates non compression. 46 | /// 47 | None, 48 | /// 49 | /// Indicates using DEFLATE. 50 | /// 51 | Deflate 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/CompressionMethod.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 990ecb6d612370f408def5e017442d1f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/ErrorEventArgs.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * ErrorEventArgs.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace WebSocketSharp 32 | { 33 | /// 34 | /// Contains the event data associated with a event. 35 | /// 36 | /// 37 | /// A event occurs when the gets an error. 38 | /// If you would like to get the error message, you should access the 39 | /// property. 40 | /// 41 | public class ErrorEventArgs : EventArgs 42 | { 43 | #region Private Fields 44 | 45 | private string _message; 46 | 47 | #endregion 48 | 49 | #region Internal Constructors 50 | 51 | internal ErrorEventArgs (string message) 52 | { 53 | _message = message; 54 | } 55 | 56 | #endregion 57 | 58 | #region Public Properties 59 | 60 | /// 61 | /// Gets the error message. 62 | /// 63 | /// 64 | /// A that represents the error message. 65 | /// 66 | public string Message { 67 | get { 68 | return _message; 69 | } 70 | } 71 | 72 | #endregion 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/ErrorEventArgs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3215f6caf074b5c4595d5ac0d352391f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Ext.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 144897afaafa3cc4a98db7590f012339 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Fin.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * Fin.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace WebSocketSharp 32 | { 33 | internal enum Fin : byte 34 | { 35 | More = 0x0, 36 | Final = 0x1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Fin.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5116139d728d9da4587f86e48e0bcf53 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/HandshakeBase.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * HandshakeBase.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | using System.Collections.Specialized; 31 | using System.Text; 32 | using WebSocketSharp.Net; 33 | 34 | namespace WebSocketSharp 35 | { 36 | internal abstract class HandshakeBase 37 | { 38 | #region Private Fields 39 | 40 | private NameValueCollection _headers; 41 | private Version _version; 42 | 43 | #endregion 44 | 45 | #region Internal Fields 46 | 47 | internal byte[] EntityBodyData; 48 | 49 | #endregion 50 | 51 | #region Protected Const Fields 52 | 53 | protected const string CrLf = "\r\n"; 54 | 55 | #endregion 56 | 57 | #region Protected Constructors 58 | 59 | protected HandshakeBase (Version version, NameValueCollection headers) 60 | { 61 | _version = version; 62 | _headers = headers; 63 | } 64 | 65 | #endregion 66 | 67 | #region Public Properties 68 | 69 | public string EntityBody { 70 | get { 71 | return EntityBodyData != null && EntityBodyData.LongLength > 0 72 | ? getEncoding (_headers["Content-Type"]).GetString (EntityBodyData) 73 | : String.Empty; 74 | } 75 | } 76 | 77 | public NameValueCollection Headers { 78 | get { 79 | return _headers; 80 | } 81 | } 82 | 83 | public Version ProtocolVersion { 84 | get { 85 | return _version; 86 | } 87 | } 88 | 89 | #endregion 90 | 91 | #region Private Methods 92 | 93 | private static Encoding getEncoding (string contentType) 94 | { 95 | if (contentType == null || contentType.Length == 0) 96 | return Encoding.UTF8; 97 | 98 | var i = contentType.IndexOf ("charset=", StringComparison.Ordinal); 99 | if (i == -1) 100 | return Encoding.UTF8; 101 | 102 | var charset = contentType.Substring (i + 8); 103 | i = charset.IndexOf (';'); 104 | if (i != -1) 105 | charset = charset.Substring (0, i); 106 | 107 | return Encoding.GetEncoding (charset); 108 | } 109 | 110 | #endregion 111 | 112 | #region Public Methods 113 | 114 | public byte[] ToByteArray () 115 | { 116 | return Encoding.UTF8.GetBytes (ToString ()); 117 | } 118 | 119 | #endregion 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/HandshakeBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe5b43f99c9141d4e99bfad6c0359e7a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/HandshakeRequest.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * HandshakeRequest.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | using System.Collections.Specialized; 31 | using System.Text; 32 | using WebSocketSharp.Net; 33 | 34 | namespace WebSocketSharp 35 | { 36 | internal class HandshakeRequest : HandshakeBase 37 | { 38 | #region Private Fields 39 | 40 | private string _method; 41 | private string _uri; 42 | private bool _websocketRequest; 43 | private bool _websocketRequestWasSet; 44 | 45 | #endregion 46 | 47 | #region Private Constructors 48 | 49 | private HandshakeRequest (Version version, NameValueCollection headers) 50 | : base (version, headers) 51 | { 52 | } 53 | 54 | #endregion 55 | 56 | #region Internal Constructors 57 | 58 | internal HandshakeRequest (string pathAndQuery) 59 | : base (HttpVersion.Version11, new NameValueCollection ()) 60 | { 61 | _uri = pathAndQuery; 62 | _method = "GET"; 63 | 64 | var headers = Headers; 65 | headers["User-Agent"] = "websocket-sharp/1.0"; 66 | headers["Upgrade"] = "websocket"; 67 | headers["Connection"] = "Upgrade"; 68 | } 69 | 70 | #endregion 71 | 72 | #region Public Properties 73 | 74 | public AuthenticationResponse AuthResponse { 75 | get { 76 | var auth = Headers["Authorization"]; 77 | return auth != null && auth.Length > 0 78 | ? AuthenticationResponse.Parse (auth) 79 | : null; 80 | } 81 | } 82 | 83 | public CookieCollection Cookies { 84 | get { 85 | return Headers.GetCookies (false); 86 | } 87 | } 88 | 89 | public string HttpMethod { 90 | get { 91 | return _method; 92 | } 93 | } 94 | 95 | public bool IsWebSocketRequest { 96 | get { 97 | if (!_websocketRequestWasSet) { 98 | var headers = Headers; 99 | _websocketRequest = _method == "GET" && 100 | ProtocolVersion > HttpVersion.Version10 && 101 | headers.Contains ("Upgrade", "websocket") && 102 | headers.Contains ("Connection", "Upgrade"); 103 | 104 | _websocketRequestWasSet = true; 105 | } 106 | 107 | return _websocketRequest; 108 | } 109 | } 110 | 111 | public string RequestUri { 112 | get { 113 | return _uri; 114 | } 115 | } 116 | 117 | #endregion 118 | 119 | #region Internal Methods 120 | 121 | internal static HandshakeRequest Parse (string[] headerParts) 122 | { 123 | var requestLine = headerParts[0].Split (new[] { ' ' }, 3); 124 | if (requestLine.Length != 3) 125 | throw new ArgumentException ("Invalid request line: " + headerParts[0]); 126 | 127 | var headers = new WebHeaderCollection (); 128 | for (int i = 1; i < headerParts.Length; i++) 129 | headers.SetInternally (headerParts[i], false); 130 | 131 | var req = new HandshakeRequest (new Version (requestLine[2].Substring (5)), headers); 132 | req._method = requestLine[0]; 133 | req._uri = requestLine[1]; 134 | 135 | return req; 136 | } 137 | 138 | #endregion 139 | 140 | #region Public Methods 141 | 142 | public void SetCookies (CookieCollection cookies) 143 | { 144 | if (cookies == null || cookies.Count == 0) 145 | return; 146 | 147 | var buff = new StringBuilder (64); 148 | foreach (var cookie in cookies.Sorted) 149 | if (!cookie.Expired) 150 | buff.AppendFormat ("{0}; ", cookie.ToString ()); 151 | 152 | var len = buff.Length; 153 | if (len > 2) { 154 | buff.Length = len - 2; 155 | Headers["Cookie"] = buff.ToString (); 156 | } 157 | } 158 | 159 | public override string ToString () 160 | { 161 | var output = new StringBuilder (64); 162 | output.AppendFormat ("{0} {1} HTTP/{2}{3}", _method, _uri, ProtocolVersion, CrLf); 163 | 164 | var headers = Headers; 165 | foreach (var key in headers.AllKeys) 166 | output.AppendFormat ("{0}: {1}{2}", key, headers[key], CrLf); 167 | 168 | output.Append (CrLf); 169 | 170 | var entity = EntityBody; 171 | if (entity.Length > 0) 172 | output.Append (entity); 173 | 174 | return output.ToString (); 175 | } 176 | 177 | #endregion 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/HandshakeRequest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2bf9efaee14d414eb4c6a81cbdb1b2a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/HandshakeResponse.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * HandshakeResponse.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | using System.Collections.Specialized; 31 | using System.Text; 32 | using WebSocketSharp.Net; 33 | 34 | namespace WebSocketSharp 35 | { 36 | internal class HandshakeResponse : HandshakeBase 37 | { 38 | #region Private Fields 39 | 40 | private string _code; 41 | private string _reason; 42 | 43 | #endregion 44 | 45 | #region Private Constructors 46 | 47 | private HandshakeResponse (Version version, NameValueCollection headers) 48 | : base (version, headers) 49 | { 50 | } 51 | 52 | #endregion 53 | 54 | #region Internal Constructors 55 | 56 | internal HandshakeResponse (HttpStatusCode code) 57 | : base (HttpVersion.Version11, new NameValueCollection ()) 58 | { 59 | _code = ((int) code).ToString (); 60 | _reason = code.GetDescription (); 61 | 62 | var headers = Headers; 63 | headers["Server"] = "websocket-sharp/1.0"; 64 | if (code == HttpStatusCode.SwitchingProtocols) { 65 | headers["Upgrade"] = "websocket"; 66 | headers["Connection"] = "Upgrade"; 67 | } 68 | } 69 | 70 | #endregion 71 | 72 | #region Public Properties 73 | 74 | public AuthenticationChallenge AuthChallenge { 75 | get { 76 | var auth = Headers["WWW-Authenticate"]; 77 | return auth != null && auth.Length > 0 78 | ? AuthenticationChallenge.Parse (auth) 79 | : null; 80 | } 81 | } 82 | 83 | public CookieCollection Cookies { 84 | get { 85 | return Headers.GetCookies (true); 86 | } 87 | } 88 | 89 | public bool IsUnauthorized { 90 | get { 91 | return _code == "401"; 92 | } 93 | } 94 | 95 | public bool IsWebSocketResponse { 96 | get { 97 | var headers = Headers; 98 | return ProtocolVersion > HttpVersion.Version10 && 99 | _code == "101" && 100 | headers.Contains ("Upgrade", "websocket") && 101 | headers.Contains ("Connection", "Upgrade"); 102 | } 103 | } 104 | 105 | public string Reason { 106 | get { 107 | return _reason; 108 | } 109 | } 110 | 111 | public string StatusCode { 112 | get { 113 | return _code; 114 | } 115 | } 116 | 117 | #endregion 118 | 119 | #region Internal Methods 120 | 121 | internal static HandshakeResponse CreateCloseResponse (HttpStatusCode code) 122 | { 123 | var res = new HandshakeResponse (code); 124 | res.Headers["Connection"] = "close"; 125 | 126 | return res; 127 | } 128 | 129 | internal static HandshakeResponse Parse (string[] headerParts) 130 | { 131 | var statusLine = headerParts[0].Split (new[] { ' ' }, 3); 132 | if (statusLine.Length != 3) 133 | throw new ArgumentException ("Invalid status line: " + headerParts[0]); 134 | 135 | var headers = new WebHeaderCollection (); 136 | for (int i = 1; i < headerParts.Length; i++) 137 | headers.SetInternally (headerParts[i], true); 138 | 139 | var res = new HandshakeResponse (new Version (statusLine[0].Substring (5)), headers); 140 | res._code = statusLine[1]; 141 | res._reason = statusLine[2]; 142 | 143 | return res; 144 | } 145 | 146 | #endregion 147 | 148 | #region Public Methods 149 | 150 | public void SetCookies (CookieCollection cookies) 151 | { 152 | if (cookies == null || cookies.Count == 0) 153 | return; 154 | 155 | var headers = Headers; 156 | foreach (var cookie in cookies.Sorted) 157 | headers.Add ("Set-Cookie", cookie.ToResponseString ()); 158 | } 159 | 160 | public override string ToString () 161 | { 162 | var output = new StringBuilder (64); 163 | output.AppendFormat ("HTTP/{0} {1} {2}{3}", ProtocolVersion, _code, _reason, CrLf); 164 | 165 | var headers = Headers; 166 | foreach (var key in headers.AllKeys) 167 | output.AppendFormat ("{0}: {1}{2}", key, headers[key], CrLf); 168 | 169 | output.Append (CrLf); 170 | 171 | var entity = EntityBody; 172 | if (entity.Length > 0) 173 | output.Append (entity); 174 | 175 | return output.ToString (); 176 | } 177 | 178 | #endregion 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/HandshakeResponse.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6cb91ebc2d29fa4fae26c77b016a491 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/LogData.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * LogData.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2013-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | using System.Diagnostics; 31 | using System.Text; 32 | 33 | namespace WebSocketSharp 34 | { 35 | /// 36 | /// Represents a log data used by the class. 37 | /// 38 | public class LogData 39 | { 40 | #region Private Fields 41 | 42 | private StackFrame _caller; 43 | private DateTime _date; 44 | private LogLevel _level; 45 | private string _message; 46 | 47 | #endregion 48 | 49 | #region Internal Constructors 50 | 51 | internal LogData (LogLevel level, StackFrame caller, string message) 52 | { 53 | _level = level; 54 | _caller = caller; 55 | _message = message ?? String.Empty; 56 | _date = DateTime.Now; 57 | } 58 | 59 | #endregion 60 | 61 | #region Public Properties 62 | 63 | /// 64 | /// Gets the information of the logging method caller. 65 | /// 66 | /// 67 | /// A that provides the information of the logging method caller. 68 | /// 69 | public StackFrame Caller { 70 | get { 71 | return _caller; 72 | } 73 | } 74 | 75 | /// 76 | /// Gets the date and time when the log data was created. 77 | /// 78 | /// 79 | /// A that represents the date and time when the log data was created. 80 | /// 81 | public DateTime Date { 82 | get { 83 | return _date; 84 | } 85 | } 86 | 87 | /// 88 | /// Gets the logging level of the log data. 89 | /// 90 | /// 91 | /// One of the enum values, indicates the logging level of the log data. 92 | /// 93 | public LogLevel Level { 94 | get { 95 | return _level; 96 | } 97 | } 98 | 99 | /// 100 | /// Gets the message of the log data. 101 | /// 102 | /// 103 | /// A that represents the message of the log data. 104 | /// 105 | public string Message { 106 | get { 107 | return _message; 108 | } 109 | } 110 | 111 | #endregion 112 | 113 | #region Public Methods 114 | 115 | /// 116 | /// Returns a that represents the current . 117 | /// 118 | /// 119 | /// A that represents the current . 120 | /// 121 | public override string ToString () 122 | { 123 | var header = String.Format ("{0}|{1,-5}|", _date, _level); 124 | var method = _caller.GetMethod (); 125 | var type = method.DeclaringType; 126 | #if DEBUG 127 | var lineNum = _caller.GetFileLineNumber (); 128 | var headerAndCaller = String.Format ( 129 | "{0}{1}.{2}:{3}|", header, type.Name, method.Name, lineNum); 130 | #else 131 | var headerAndCaller = String.Format ("{0}{1}.{2}|", header, type.Name, method.Name); 132 | #endif 133 | 134 | var messages = _message.Replace ("\r\n", "\n").TrimEnd ('\n').Split ('\n'); 135 | if (messages.Length <= 1) 136 | return String.Format ("{0}{1}", headerAndCaller, _message); 137 | 138 | var log = new StringBuilder ( 139 | String.Format ("{0}{1}\n", headerAndCaller, messages [0]), 64); 140 | 141 | var space = header.Length; 142 | var format = String.Format ("{{0,{0}}}{{1}}\n", space); 143 | for (var i = 1; i < messages.Length; i++) 144 | log.AppendFormat (format, "", messages [i]); 145 | 146 | log.Length--; 147 | return log.ToString (); 148 | } 149 | 150 | #endregion 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/LogData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8635c86a5edac7e4aa95d5d71571206c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/LogLevel.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * LogLevel.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2013-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace WebSocketSharp 32 | { 33 | /// 34 | /// Contains the values of the logging level. 35 | /// 36 | public enum LogLevel 37 | { 38 | /// 39 | /// Indicates the bottom logging level. 40 | /// 41 | Trace, 42 | /// 43 | /// Indicates the 2nd logging level from the bottom. 44 | /// 45 | Debug, 46 | /// 47 | /// Indicates the 3rd logging level from the bottom. 48 | /// 49 | Info, 50 | /// 51 | /// Indicates the 3rd logging level from the top. 52 | /// 53 | Warn, 54 | /// 55 | /// Indicates the 2nd logging level from the top. 56 | /// 57 | Error, 58 | /// 59 | /// Indicates the top logging level. 60 | /// 61 | Fatal 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/LogLevel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 27c64de5c5518d44c8769f8cc754fc94 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Logger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b9b20c2797001e4896a1d5b84dcafd3 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Mask.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * Mask.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace WebSocketSharp 32 | { 33 | internal enum Mask : byte 34 | { 35 | Unmask = 0x0, 36 | Mask = 0x1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Mask.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9b4485e7626b594bafabc101905288a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/MessageEventArgs.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * MessageEventArgs.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2013 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | using System.Text; 31 | 32 | namespace WebSocketSharp 33 | { 34 | /// 35 | /// Contains the event data associated with a event. 36 | /// 37 | /// 38 | /// A event occurs when the receives 39 | /// a text or binary data frame. 40 | /// If you want to get the received data, you access the or 41 | /// property. 42 | /// 43 | public class MessageEventArgs : EventArgs 44 | { 45 | #region Private Fields 46 | 47 | private string _data; 48 | private Opcode _opcode; 49 | private byte[] _rawData; 50 | 51 | #endregion 52 | 53 | #region Internal Constructors 54 | 55 | internal MessageEventArgs (Opcode opcode, byte[] data) 56 | { 57 | if ((ulong) data.LongLength > PayloadData.MaxLength) 58 | throw new WebSocketException (CloseStatusCode.TooBig); 59 | 60 | _opcode = opcode; 61 | _rawData = data; 62 | _data = convertToString (opcode, data); 63 | } 64 | 65 | internal MessageEventArgs (Opcode opcode, PayloadData payload) 66 | { 67 | _opcode = opcode; 68 | _rawData = payload.ApplicationData; 69 | _data = convertToString (opcode, _rawData); 70 | } 71 | 72 | #endregion 73 | 74 | #region Public Properties 75 | 76 | /// 77 | /// Gets the received data as a . 78 | /// 79 | /// 80 | /// A that contains the received data. 81 | /// 82 | public string Data { 83 | get { 84 | return _data; 85 | } 86 | } 87 | 88 | /// 89 | /// Gets the received data as an array of . 90 | /// 91 | /// 92 | /// An array of that contains the received data. 93 | /// 94 | public byte [] RawData { 95 | get { 96 | return _rawData; 97 | } 98 | } 99 | 100 | /// 101 | /// Gets the type of the received data. 102 | /// 103 | /// 104 | /// One of the values, indicates the type of the received data. 105 | /// 106 | public Opcode Type { 107 | get { 108 | return _opcode; 109 | } 110 | } 111 | 112 | #endregion 113 | 114 | #region Private Methods 115 | 116 | private static string convertToString (Opcode opcode, byte [] data) 117 | { 118 | return data.LongLength == 0 119 | ? String.Empty 120 | : opcode == Opcode.Text 121 | ? Encoding.UTF8.GetString (data) 122 | : opcode.ToString (); 123 | } 124 | 125 | #endregion 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/MessageEventArgs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7206e89bff762404ea8667aa83a42f52 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5227a121ade52274a8233e15eac32ad9 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/AuthenticationBase.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * AuthenticationBase.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | using System.Collections.Specialized; 31 | using System.Text; 32 | 33 | namespace WebSocketSharp.Net 34 | { 35 | internal abstract class AuthenticationBase 36 | { 37 | #region Private Fields 38 | 39 | private AuthenticationSchemes _scheme; 40 | 41 | #endregion 42 | 43 | #region Internal Fields 44 | 45 | internal NameValueCollection Parameters; 46 | 47 | #endregion 48 | 49 | #region Protected Constructors 50 | 51 | protected AuthenticationBase (AuthenticationSchemes scheme, NameValueCollection parameters) 52 | { 53 | _scheme = scheme; 54 | Parameters = parameters; 55 | } 56 | 57 | #endregion 58 | 59 | #region Public Properties 60 | 61 | public string Algorithm { 62 | get { 63 | return Parameters["algorithm"]; 64 | } 65 | } 66 | 67 | public string Nonce { 68 | get { 69 | return Parameters["nonce"]; 70 | } 71 | } 72 | 73 | public string Opaque { 74 | get { 75 | return Parameters["opaque"]; 76 | } 77 | } 78 | 79 | public string Qop { 80 | get { 81 | return Parameters["qop"]; 82 | } 83 | } 84 | 85 | public string Realm { 86 | get { 87 | return Parameters["realm"]; 88 | } 89 | } 90 | 91 | public AuthenticationSchemes Scheme { 92 | get { 93 | return _scheme; 94 | } 95 | } 96 | 97 | #endregion 98 | 99 | #region Internal Methods 100 | 101 | internal static string CreateNonceValue () 102 | { 103 | var src = new byte[16]; 104 | var rand = new Random (); 105 | rand.NextBytes (src); 106 | 107 | var res = new StringBuilder (32); 108 | foreach (var b in src) 109 | res.Append (b.ToString ("x2")); 110 | 111 | return res.ToString (); 112 | } 113 | 114 | internal static NameValueCollection ParseParameters (string value) 115 | { 116 | var res = new NameValueCollection (); 117 | foreach (var param in value.SplitHeaderValue (',')) { 118 | var i = param.IndexOf ('='); 119 | var name = i > 0 ? param.Substring (0, i).Trim () : null; 120 | var val = i < 0 121 | ? param.Trim ().Trim ('"') 122 | : i < param.Length - 1 123 | ? param.Substring (i + 1).Trim ().Trim ('"') 124 | : String.Empty; 125 | 126 | res.Add (name, val); 127 | } 128 | 129 | return res; 130 | } 131 | 132 | internal abstract string ToBasicString (); 133 | 134 | internal abstract string ToDigestString (); 135 | 136 | #endregion 137 | 138 | #region Public Methods 139 | 140 | public override string ToString () 141 | { 142 | return _scheme == AuthenticationSchemes.Basic 143 | ? ToBasicString () 144 | : _scheme == AuthenticationSchemes.Digest 145 | ? ToDigestString () 146 | : String.Empty; 147 | } 148 | 149 | #endregion 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/AuthenticationBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 910cdcca401a9924697b5a4caa654421 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/AuthenticationChallenge.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * AuthenticationChallenge.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2013-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | using System.Collections.Specialized; 31 | using System.Text; 32 | 33 | namespace WebSocketSharp.Net 34 | { 35 | internal class AuthenticationChallenge : AuthenticationBase 36 | { 37 | #region Private Constructors 38 | 39 | private AuthenticationChallenge (AuthenticationSchemes scheme, NameValueCollection parameters) 40 | : base (scheme, parameters) 41 | { 42 | } 43 | 44 | #endregion 45 | 46 | #region Internal Constructors 47 | 48 | internal AuthenticationChallenge (AuthenticationSchemes scheme, string realm) 49 | : base (scheme, new NameValueCollection ()) 50 | { 51 | Parameters["realm"] = realm; 52 | if (scheme == AuthenticationSchemes.Digest) { 53 | Parameters["nonce"] = CreateNonceValue (); 54 | Parameters["algorithm"] = "MD5"; 55 | Parameters["qop"] = "auth"; 56 | } 57 | } 58 | 59 | #endregion 60 | 61 | #region Public Properties 62 | 63 | public string Domain { 64 | get { 65 | return Parameters["domain"]; 66 | } 67 | } 68 | 69 | public string Stale { 70 | get { 71 | return Parameters["stale"]; 72 | } 73 | } 74 | 75 | #endregion 76 | 77 | #region Internal Methods 78 | 79 | internal static AuthenticationChallenge CreateBasicChallenge (string realm) 80 | { 81 | return new AuthenticationChallenge (AuthenticationSchemes.Basic, realm); 82 | } 83 | 84 | internal static AuthenticationChallenge CreateDigestChallenge (string realm) 85 | { 86 | return new AuthenticationChallenge (AuthenticationSchemes.Digest, realm); 87 | } 88 | 89 | internal static AuthenticationChallenge Parse (string value) 90 | { 91 | var chal = value.Split (new[] { ' ' }, 2); 92 | if (chal.Length != 2) 93 | return null; 94 | 95 | var schm = chal[0].ToLower (); 96 | return schm == "basic" 97 | ? new AuthenticationChallenge ( 98 | AuthenticationSchemes.Basic, ParseParameters (chal[1])) 99 | : schm == "digest" 100 | ? new AuthenticationChallenge ( 101 | AuthenticationSchemes.Digest, ParseParameters (chal[1])) 102 | : null; 103 | } 104 | 105 | internal override string ToBasicString () 106 | { 107 | return String.Format ("Basic realm=\"{0}\"", Parameters["realm"]); 108 | } 109 | 110 | internal override string ToDigestString () 111 | { 112 | var output = new StringBuilder (128); 113 | 114 | var domain = Parameters["domain"]; 115 | if (domain != null) 116 | output.AppendFormat ( 117 | "Digest realm=\"{0}\", domain=\"{1}\", nonce=\"{2}\"", 118 | Parameters["realm"], 119 | domain, 120 | Parameters["nonce"]); 121 | else 122 | output.AppendFormat ( 123 | "Digest realm=\"{0}\", nonce=\"{1}\"", Parameters["realm"], Parameters["nonce"]); 124 | 125 | var opaque = Parameters["opaque"]; 126 | if (opaque != null) 127 | output.AppendFormat (", opaque=\"{0}\"", opaque); 128 | 129 | var stale = Parameters["stale"]; 130 | if (stale != null) 131 | output.AppendFormat (", stale={0}", stale); 132 | 133 | var algo = Parameters["algorithm"]; 134 | if (algo != null) 135 | output.AppendFormat (", algorithm={0}", algo); 136 | 137 | var qop = Parameters["qop"]; 138 | if (qop != null) 139 | output.AppendFormat (", qop=\"{0}\"", qop); 140 | 141 | return output.ToString (); 142 | } 143 | 144 | #endregion 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/AuthenticationChallenge.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02402f9bf7e946a4fa6749872bdd33d0 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/AuthenticationResponse.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 156616d94d5d5ee4bb1788faf05804ef 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/AuthenticationSchemes.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * AuthenticationSchemes.cs 4 | * 5 | * This code is derived from System.Net.AuthenticationSchemes.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) 11 | * Copyright (c) 2012-2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Atsushi Enomoto 37 | */ 38 | #endregion 39 | 40 | using System; 41 | 42 | namespace WebSocketSharp.Net 43 | { 44 | /// 45 | /// Contains the values of the schemes for authentication. 46 | /// 47 | [Flags] 48 | public enum AuthenticationSchemes 49 | { 50 | /// 51 | /// Indicates that no authentication is allowed. 52 | /// 53 | None, 54 | /// 55 | /// Indicates digest authentication. 56 | /// 57 | Digest = 1, 58 | /// 59 | /// Indicates basic authentication. 60 | /// 61 | Basic = 8, 62 | /// 63 | /// Indicates anonymous authentication. 64 | /// 65 | Anonymous = 0x8000 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/AuthenticationSchemes.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 176175dab868d194291cd7370a980e76 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/Chunk.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * Chunk.cs 4 | * 5 | * This code is derived from System.Net.ChunkStream.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2003 Ximian, Inc (http://www.ximian.com) 11 | * Copyright (c) 2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Gonzalo Paniagua Javier 37 | */ 38 | #endregion 39 | 40 | using System; 41 | 42 | namespace WebSocketSharp.Net 43 | { 44 | internal class Chunk 45 | { 46 | #region Private Fields 47 | 48 | private byte [] _data; 49 | private int _offset; 50 | 51 | #endregion 52 | 53 | #region Public Constructors 54 | 55 | public Chunk (byte [] data) 56 | { 57 | _data = data; 58 | } 59 | 60 | #endregion 61 | 62 | #region Public Properties 63 | 64 | public int ReadLeft { 65 | get { 66 | return _data.Length - _offset; 67 | } 68 | } 69 | 70 | #endregion 71 | 72 | #region Public Methods 73 | 74 | public int Read (byte [] buffer, int offset, int size) 75 | { 76 | var left = _data.Length - _offset; 77 | if (left == 0) 78 | return left; 79 | 80 | if (size > left) 81 | size = left; 82 | 83 | Buffer.BlockCopy (_data, _offset, buffer, offset, size); 84 | _offset += size; 85 | 86 | return size; 87 | } 88 | 89 | #endregion 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/Chunk.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 024d2731b29683144af3be58152d7e95 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/ChunkStream.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3258eeefc74d97b4d91d81fa3c883e7c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/ChunkedRequestStream.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * ChunkedRequestStream.cs 4 | * 5 | * This code is derived from System.Net.ChunkedInputStream.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) 11 | * Copyright (c) 2012-2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Gonzalo Paniagua Javier 37 | */ 38 | #endregion 39 | 40 | using System; 41 | using System.IO; 42 | 43 | namespace WebSocketSharp.Net 44 | { 45 | internal class ChunkedRequestStream : RequestStream 46 | { 47 | #region Private Const Fields 48 | 49 | private const int _bufferSize = 8192; 50 | 51 | #endregion 52 | 53 | #region Private Fields 54 | 55 | private HttpListenerContext _context; 56 | private ChunkStream _decoder; 57 | private bool _disposed; 58 | private bool _noMoreData; 59 | 60 | #endregion 61 | 62 | #region Public Constructors 63 | 64 | public ChunkedRequestStream ( 65 | HttpListenerContext context, Stream stream, byte [] buffer, int offset, int length) 66 | : base (stream, buffer, offset, length) 67 | { 68 | _context = context; 69 | _decoder = new ChunkStream ((WebHeaderCollection) context.Request.Headers); 70 | } 71 | 72 | #endregion 73 | 74 | #region Public Properties 75 | 76 | public ChunkStream Decoder { 77 | get { 78 | return _decoder; 79 | } 80 | 81 | set { 82 | _decoder = value; 83 | } 84 | } 85 | 86 | #endregion 87 | 88 | #region Private Methods 89 | 90 | private void onRead (IAsyncResult asyncResult) 91 | { 92 | var readState = (ReadBufferState) asyncResult.AsyncState; 93 | var ares = readState.AsyncResult; 94 | try { 95 | var nread = base.EndRead (asyncResult); 96 | _decoder.Write (ares.Buffer, ares.Offset, nread); 97 | nread = _decoder.Read (readState.Buffer, readState.Offset, readState.Count); 98 | readState.Offset += nread; 99 | readState.Count -= nread; 100 | if (readState.Count == 0 || !_decoder.WantMore || nread == 0) { 101 | _noMoreData = !_decoder.WantMore && nread == 0; 102 | ares.Count = readState.InitialCount - readState.Count; 103 | ares.Complete (); 104 | 105 | return; 106 | } 107 | 108 | ares.Offset = 0; 109 | ares.Count = Math.Min (_bufferSize, _decoder.ChunkLeft + 6); 110 | base.BeginRead (ares.Buffer, ares.Offset, ares.Count, onRead, readState); 111 | } 112 | catch (Exception ex) { 113 | _context.Connection.SendError (ex.Message, 400); 114 | ares.Complete (ex); 115 | } 116 | } 117 | 118 | #endregion 119 | 120 | #region Public Methods 121 | 122 | public override IAsyncResult BeginRead ( 123 | byte [] buffer, int offset, int count, AsyncCallback callback, object state) 124 | { 125 | if (_disposed) 126 | throw new ObjectDisposedException (GetType ().ToString ()); 127 | 128 | if (buffer == null) 129 | throw new ArgumentNullException ("buffer"); 130 | 131 | var len = buffer.Length; 132 | if (offset < 0 || offset > len) 133 | throw new ArgumentOutOfRangeException ("'offset' exceeds the size of buffer."); 134 | 135 | if (count < 0 || offset > len - count) 136 | throw new ArgumentOutOfRangeException ("'offset' + 'count' exceeds the size of buffer."); 137 | 138 | var ares = new HttpStreamAsyncResult (callback, state); 139 | if (_noMoreData) { 140 | ares.Complete (); 141 | return ares; 142 | } 143 | 144 | var nread = _decoder.Read (buffer, offset, count); 145 | offset += nread; 146 | count -= nread; 147 | if (count == 0) { 148 | // Got all we wanted, no need to bother the decoder yet. 149 | ares.Count = nread; 150 | ares.Complete (); 151 | 152 | return ares; 153 | } 154 | 155 | if (!_decoder.WantMore) { 156 | _noMoreData = nread == 0; 157 | ares.Count = nread; 158 | ares.Complete (); 159 | 160 | return ares; 161 | } 162 | 163 | ares.Buffer = new byte [_bufferSize]; 164 | ares.Offset = 0; 165 | ares.Count = _bufferSize; 166 | 167 | var readState = new ReadBufferState (buffer, offset, count, ares); 168 | readState.InitialCount += nread; 169 | base.BeginRead (ares.Buffer, ares.Offset, ares.Count, onRead, readState); 170 | 171 | return ares; 172 | } 173 | 174 | public override void Close () 175 | { 176 | if (_disposed) 177 | return; 178 | 179 | _disposed = true; 180 | base.Close (); 181 | } 182 | 183 | public override int EndRead (IAsyncResult asyncResult) 184 | { 185 | if (_disposed) 186 | throw new ObjectDisposedException (GetType ().ToString ()); 187 | 188 | if (asyncResult == null) 189 | throw new ArgumentNullException ("asyncResult"); 190 | 191 | var ares = asyncResult as HttpStreamAsyncResult; 192 | if (ares == null) 193 | throw new ArgumentException ("Wrong IAsyncResult.", "asyncResult"); 194 | 195 | if (!ares.IsCompleted) 196 | ares.AsyncWaitHandle.WaitOne (); 197 | 198 | if (ares.Error != null) 199 | throw new HttpListenerException (400, "I/O operation aborted."); 200 | 201 | return ares.Count; 202 | } 203 | 204 | public override int Read (byte [] buffer, int offset, int count) 205 | { 206 | var ares = BeginRead (buffer, offset, count, null, null); 207 | return EndRead (ares); 208 | } 209 | 210 | #endregion 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/ChunkedRequestStream.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc6a5a78a833514469846f16f1e26749 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/Cookie.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: daebe88ca64ea0146890c1cb8eb8e27f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/CookieCollection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1de67737c8552804583f8eafee33c4e0 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/CookieException.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * CookieException.cs 4 | * 5 | * This code is derived from System.Net.CookieException.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2012-2014 sta.blockhead 11 | * 12 | * Permission is hereby granted, free of charge, to any person obtaining a copy 13 | * of this software and associated documentation files (the "Software"), to deal 14 | * in the Software without restriction, including without limitation the rights 15 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | * copies of the Software, and to permit persons to whom the Software is 17 | * furnished to do so, subject to the following conditions: 18 | * 19 | * The above copyright notice and this permission notice shall be included in 20 | * all copies or substantial portions of the Software. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | * THE SOFTWARE. 29 | */ 30 | #endregion 31 | 32 | #region Authors 33 | /* 34 | * Authors: 35 | * - Lawrence Pit 36 | */ 37 | #endregion 38 | 39 | using System; 40 | using System.Runtime.Serialization; 41 | using System.Security.Permissions; 42 | 43 | namespace WebSocketSharp.Net 44 | { 45 | /// 46 | /// The exception that is thrown when a gets an error. 47 | /// 48 | [Serializable] 49 | public class CookieException : FormatException, ISerializable 50 | { 51 | #region Internal Constructors 52 | 53 | internal CookieException (string message) 54 | : base (message) 55 | { 56 | } 57 | 58 | internal CookieException (string message, Exception innerException) 59 | : base (message, innerException) 60 | { 61 | } 62 | 63 | #endregion 64 | 65 | #region Protected Constructors 66 | 67 | /// 68 | /// Initializes a new instance of the class from 69 | /// the specified and . 70 | /// 71 | /// 72 | /// A that contains the serialized object data. 73 | /// 74 | /// 75 | /// A that specifies the source for the deserialization. 76 | /// 77 | protected CookieException ( 78 | SerializationInfo serializationInfo, StreamingContext streamingContext) 79 | : base (serializationInfo, streamingContext) 80 | { 81 | } 82 | 83 | #endregion 84 | 85 | #region Public Constructors 86 | 87 | /// 88 | /// Initializes a new instance of the class. 89 | /// 90 | public CookieException () 91 | : base () 92 | { 93 | } 94 | 95 | #endregion 96 | 97 | #region Public Methods 98 | 99 | /// 100 | /// Populates the specified with the data needed to serialize 101 | /// the current . 102 | /// 103 | /// 104 | /// A that holds the serialized object data. 105 | /// 106 | /// 107 | /// A that specifies the destination for the serialization. 108 | /// 109 | /** 110 | * FIXME: Removed to avoid Unity warnings 111 | * [SecurityPermission ( 112 | * SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)] 113 | */ 114 | public override void GetObjectData ( 115 | SerializationInfo serializationInfo, StreamingContext streamingContext) 116 | { 117 | base.GetObjectData (serializationInfo, streamingContext); 118 | } 119 | 120 | #endregion 121 | 122 | #region Explicit Interface Implementation 123 | 124 | /// 125 | /// Populates the specified with the data needed to serialize 126 | /// the current . 127 | /// 128 | /// 129 | /// A that holds the serialized object data. 130 | /// 131 | /// 132 | /// A that specifies the destination for the serialization. 133 | /// 134 | /** 135 | * FIXME: Removed to avoid Unity warnings 136 | * [SecurityPermission ( 137 | * SecurityAction.LinkDemand, 138 | * Flags = SecurityPermissionFlag.SerializationFormatter, 139 | * SerializationFormatter = true)] 140 | */ 141 | void ISerializable.GetObjectData ( 142 | SerializationInfo serializationInfo, StreamingContext streamingContext) 143 | { 144 | base.GetObjectData (serializationInfo, streamingContext); 145 | } 146 | 147 | #endregion 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/CookieException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d31f64ba18153d640928c6efbe14570b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/EndPointListener.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a97d8730eff548644883a34cc4eac68d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/EndPointManager.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * EndPointManager.cs 4 | * 5 | * This code is derived from System.Net.EndPointManager.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) 11 | * Copyright (c) 2012-2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Gonzalo Paniagua Javier 37 | */ 38 | #endregion 39 | 40 | using System; 41 | using System.Collections; 42 | using System.Collections.Generic; 43 | using System.Net; 44 | 45 | namespace WebSocketSharp.Net 46 | { 47 | internal sealed class EndPointManager 48 | { 49 | #region Private Static Fields 50 | 51 | private static Dictionary> _ipToEndpoints = 52 | new Dictionary> (); 53 | 54 | #endregion 55 | 56 | #region Private Constructors 57 | 58 | private EndPointManager () 59 | { 60 | } 61 | 62 | #endregion 63 | 64 | #region Private Methods 65 | 66 | private static void addPrefix (string uriPrefix, HttpListener httpListener) 67 | { 68 | var prefix = new ListenerPrefix (uriPrefix); 69 | if (prefix.Path.IndexOf ('%') != -1) 70 | throw new HttpListenerException (400, "Invalid path."); // TODO: Code? 71 | 72 | if (prefix.Path.IndexOf ("//", StringComparison.Ordinal) != -1) 73 | throw new HttpListenerException (400, "Invalid path."); // TODO: Code? 74 | 75 | // Always listens on all the interfaces, no matter the host name/ip used. 76 | var epListener = getEndPointListener ( 77 | IPAddress.Any, prefix.Port, httpListener, prefix.Secure); 78 | 79 | epListener.AddPrefix (prefix, httpListener); 80 | } 81 | 82 | private static EndPointListener getEndPointListener ( 83 | IPAddress address, int port, HttpListener httpListener, bool secure) 84 | { 85 | Dictionary endpoints = null; 86 | if (_ipToEndpoints.ContainsKey (address)) { 87 | endpoints = _ipToEndpoints [address]; 88 | } 89 | else { 90 | endpoints = new Dictionary (); 91 | _ipToEndpoints [address] = endpoints; 92 | } 93 | 94 | EndPointListener epListener = null; 95 | if (endpoints.ContainsKey (port)) { 96 | epListener = endpoints [port]; 97 | } 98 | else { 99 | epListener = new EndPointListener ( 100 | address, 101 | port, 102 | secure, 103 | httpListener.CertificateFolderPath, 104 | httpListener.DefaultCertificate); 105 | 106 | endpoints [port] = epListener; 107 | } 108 | 109 | return epListener; 110 | } 111 | 112 | private static void removePrefix (string uriPrefix, HttpListener httpListener) 113 | { 114 | var prefix = new ListenerPrefix (uriPrefix); 115 | if (prefix.Path.IndexOf ('%') != -1) 116 | return; 117 | 118 | if (prefix.Path.IndexOf ("//", StringComparison.Ordinal) != -1) 119 | return; 120 | 121 | var epListener = getEndPointListener ( 122 | IPAddress.Any, prefix.Port, httpListener, prefix.Secure); 123 | 124 | epListener.RemovePrefix (prefix, httpListener); 125 | } 126 | 127 | #endregion 128 | 129 | #region Public Methods 130 | 131 | public static void AddListener (HttpListener httpListener) 132 | { 133 | var added = new List (); 134 | lock (((ICollection) _ipToEndpoints).SyncRoot) { 135 | try { 136 | foreach (var prefix in httpListener.Prefixes) { 137 | addPrefix (prefix, httpListener); 138 | added.Add (prefix); 139 | } 140 | } 141 | catch { 142 | foreach (var prefix in added) 143 | removePrefix (prefix, httpListener); 144 | 145 | throw; 146 | } 147 | } 148 | } 149 | 150 | public static void AddPrefix (string uriPrefix, HttpListener httpListener) 151 | { 152 | lock (((ICollection) _ipToEndpoints).SyncRoot) 153 | addPrefix (uriPrefix, httpListener); 154 | } 155 | 156 | public static void RemoveEndPoint (EndPointListener epListener, IPEndPoint endpoint) 157 | { 158 | lock (((ICollection) _ipToEndpoints).SyncRoot) { 159 | var endpoints = _ipToEndpoints [endpoint.Address]; 160 | endpoints.Remove (endpoint.Port); 161 | if (endpoints.Count == 0) 162 | _ipToEndpoints.Remove (endpoint.Address); 163 | 164 | epListener.Close (); 165 | } 166 | } 167 | 168 | public static void RemoveListener (HttpListener httpListener) 169 | { 170 | lock (((ICollection) _ipToEndpoints).SyncRoot) 171 | foreach (var prefix in httpListener.Prefixes) 172 | removePrefix (prefix, httpListener); 173 | } 174 | 175 | public static void RemovePrefix (string uriPrefix, HttpListener httpListener) 176 | { 177 | lock (((ICollection) _ipToEndpoints).SyncRoot) 178 | removePrefix (uriPrefix, httpListener); 179 | } 180 | 181 | #endregion 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/EndPointManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a7c160bcf87fca48a3f481f4615ea53 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpBasicIdentity.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * HttpBasicIdentity.cs 4 | * 5 | * This code is derived from System.Net.HttpListenerBasicIdentity.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) 11 | * Copyright (c) 2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Gonzalo Paniagua Javier 37 | */ 38 | #endregion 39 | 40 | using System; 41 | using System.Security.Principal; 42 | 43 | namespace WebSocketSharp.Net 44 | { 45 | /// 46 | /// Holds the user name and password from the HTTP Basic authentication credentials. 47 | /// 48 | public class HttpBasicIdentity : GenericIdentity 49 | { 50 | #region Private Fields 51 | 52 | private string _password; 53 | 54 | #endregion 55 | 56 | #region internal Constructors 57 | 58 | internal HttpBasicIdentity (string username, string password) 59 | : base (username, "Basic") 60 | { 61 | _password = password; 62 | } 63 | 64 | #endregion 65 | 66 | #region Public Properties 67 | 68 | /// 69 | /// Gets the password from the HTTP Basic authentication credentials. 70 | /// 71 | /// 72 | /// A that represents the password. 73 | /// 74 | public virtual string Password { 75 | get { 76 | return _password; 77 | } 78 | } 79 | 80 | #endregion 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpBasicIdentity.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4c26c419a36603d438160d63c60759ad 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpConnection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b74ef60f30bf36d4f9f65782d8334903 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpDigestIdentity.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * HttpDigestIdentity.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | using System.Collections.Specialized; 31 | using System.Security.Principal; 32 | 33 | namespace WebSocketSharp.Net 34 | { 35 | /// 36 | /// Holds the user name and other parameters from the HTTP Digest authentication credentials. 37 | /// 38 | public class HttpDigestIdentity : GenericIdentity 39 | { 40 | #region Private Fields 41 | 42 | private NameValueCollection _parameters; 43 | 44 | #endregion 45 | 46 | #region Internal Constructors 47 | 48 | internal HttpDigestIdentity (NameValueCollection parameters) 49 | : base (parameters ["username"], "Digest") 50 | { 51 | _parameters = parameters; 52 | } 53 | 54 | #endregion 55 | 56 | #region Public Properties 57 | 58 | /// 59 | /// Gets the algorithm parameter from the HTTP Digest authentication credentials. 60 | /// 61 | /// 62 | /// A that represents the algorithm parameter. 63 | /// 64 | public string Algorithm { 65 | get { 66 | return _parameters ["algorithm"]; 67 | } 68 | } 69 | 70 | /// 71 | /// Gets the cnonce parameter from the HTTP Digest authentication credentials. 72 | /// 73 | /// 74 | /// A that represents the cnonce parameter. 75 | /// 76 | public string Cnonce { 77 | get { 78 | return _parameters ["cnonce"]; 79 | } 80 | } 81 | 82 | /// 83 | /// Gets the nc parameter from the HTTP Digest authentication credentials. 84 | /// 85 | /// 86 | /// A that represents the nc parameter. 87 | /// 88 | public string Nc { 89 | get { 90 | return _parameters ["nc"]; 91 | } 92 | } 93 | 94 | /// 95 | /// Gets the nonce parameter from the HTTP Digest authentication credentials. 96 | /// 97 | /// 98 | /// A that represents the nonce parameter. 99 | /// 100 | public string Nonce { 101 | get { 102 | return _parameters ["nonce"]; 103 | } 104 | } 105 | 106 | /// 107 | /// Gets the opaque parameter from the HTTP Digest authentication credentials. 108 | /// 109 | /// 110 | /// A that represents the opaque parameter. 111 | /// 112 | public string Opaque { 113 | get { 114 | return _parameters ["opaque"]; 115 | } 116 | } 117 | 118 | /// 119 | /// Gets the qop parameter from the HTTP Digest authentication credentials. 120 | /// 121 | /// 122 | /// A that represents the qop parameter. 123 | /// 124 | public string Qop { 125 | get { 126 | return _parameters ["qop"]; 127 | } 128 | } 129 | 130 | /// 131 | /// Gets the realm parameter from the HTTP Digest authentication credentials. 132 | /// 133 | /// 134 | /// A that represents the realm parameter. 135 | /// 136 | public string Realm { 137 | get { 138 | return _parameters ["realm"]; 139 | } 140 | } 141 | 142 | /// 143 | /// Gets the response parameter from the HTTP Digest authentication credentials. 144 | /// 145 | /// 146 | /// A that represents the response parameter. 147 | /// 148 | public string Response { 149 | get { 150 | return _parameters ["response"]; 151 | } 152 | } 153 | 154 | /// 155 | /// Gets the uri parameter from the HTTP Digest authentication credentials. 156 | /// 157 | /// 158 | /// A that represents the uri parameter. 159 | /// 160 | public string Uri { 161 | get { 162 | return _parameters ["uri"]; 163 | } 164 | } 165 | 166 | #endregion 167 | 168 | #region Internal Methods 169 | 170 | internal bool IsValid (string password, string realm, string method, string entity) 171 | { 172 | var parameters = new NameValueCollection (_parameters); 173 | parameters ["password"] = password; 174 | parameters ["realm"] = realm; 175 | parameters ["method"] = method; 176 | parameters ["entity"] = entity; 177 | 178 | return _parameters ["response"] == AuthenticationResponse.CreateRequestDigest (parameters); 179 | } 180 | 181 | #endregion 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpDigestIdentity.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f8937a933f76e347ae4a12fc1bbd307 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpHeaderInfo.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * HttpHeaderInfo.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2013-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace WebSocketSharp.Net 32 | { 33 | internal class HttpHeaderInfo 34 | { 35 | #region Private Fields 36 | 37 | private HttpHeaderType _type; 38 | 39 | #endregion 40 | 41 | #region Public Constructors 42 | 43 | public HttpHeaderInfo () 44 | { 45 | } 46 | 47 | #endregion 48 | 49 | #region Internal Properties 50 | 51 | internal bool IsMultiValueInRequest { 52 | get { 53 | return (_type & HttpHeaderType.MultiValueInRequest) == HttpHeaderType.MultiValueInRequest; 54 | } 55 | } 56 | 57 | internal bool IsMultiValueInResponse { 58 | get { 59 | return (_type & HttpHeaderType.MultiValueInResponse) == HttpHeaderType.MultiValueInResponse; 60 | } 61 | } 62 | 63 | #endregion 64 | 65 | #region Public Properties 66 | 67 | public bool IsRequest { 68 | get { 69 | return (_type & HttpHeaderType.Request) == HttpHeaderType.Request; 70 | } 71 | } 72 | 73 | public bool IsResponse { 74 | get { 75 | return (_type & HttpHeaderType.Response) == HttpHeaderType.Response; 76 | } 77 | } 78 | 79 | public string Name { 80 | get; set; 81 | } 82 | 83 | public HttpHeaderType Type { 84 | get { 85 | return _type; 86 | } 87 | 88 | set { 89 | _type = value; 90 | } 91 | } 92 | 93 | #endregion 94 | 95 | #region Public Methods 96 | 97 | public bool IsMultiValue (bool response) 98 | { 99 | return (_type & HttpHeaderType.MultiValue) != HttpHeaderType.MultiValue 100 | ? response 101 | ? IsMultiValueInResponse 102 | : IsMultiValueInRequest 103 | : response 104 | ? IsResponse 105 | : IsRequest; 106 | } 107 | 108 | public bool IsRestricted (bool response) 109 | { 110 | return (_type & HttpHeaderType.Restricted) != HttpHeaderType.Restricted 111 | ? false 112 | : response 113 | ? IsResponse 114 | : IsRequest; 115 | } 116 | 117 | #endregion 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpHeaderInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6357da8a4644b7240b5af4214a8ae2d4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpHeaderType.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * HttpHeaderType.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2013-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace WebSocketSharp.Net 32 | { 33 | [Flags] 34 | internal enum HttpHeaderType 35 | { 36 | Unspecified = 0, 37 | Request = 1, 38 | Response = 1 << 1, 39 | Restricted = 1 << 2, 40 | MultiValue = 1 << 3, 41 | MultiValueInRequest = 1 << 4, 42 | MultiValueInResponse = 1 << 5 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpHeaderType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b01082e447b0084cbdad3796343c597 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpListener.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a424a80e4de6074290037399bfb50ef 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpListenerContext.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6590397730b7c564a91f42ff33fc9ea6 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpListenerException.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * HttpListenerException.cs 4 | * 5 | * This code is derived from System.Net.HttpListenerException.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) 11 | * Copyright (c) 2012-2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Gonzalo Paniagua Javier 37 | */ 38 | #endregion 39 | 40 | using System; 41 | using System.ComponentModel; 42 | using System.Runtime.Serialization; 43 | 44 | namespace WebSocketSharp.Net 45 | { 46 | /// 47 | /// The exception that is thrown when a gets an error 48 | /// processing an HTTP request. 49 | /// 50 | [Serializable] 51 | public class HttpListenerException : Win32Exception 52 | { 53 | #region Protected Constructors 54 | 55 | /// 56 | /// Initializes a new instance of the class from 57 | /// the specified and . 58 | /// 59 | /// 60 | /// A that contains the serialized object data. 61 | /// 62 | /// 63 | /// A that specifies the source for the deserialization. 64 | /// 65 | protected HttpListenerException ( 66 | SerializationInfo serializationInfo, StreamingContext streamingContext) 67 | : base (serializationInfo, streamingContext) 68 | { 69 | } 70 | 71 | #endregion 72 | 73 | #region Public Constructors 74 | 75 | /// 76 | /// Initializes a new instance of the class. 77 | /// 78 | public HttpListenerException () 79 | { 80 | } 81 | 82 | /// 83 | /// Initializes a new instance of the class 84 | /// with the specified . 85 | /// 86 | /// 87 | /// An that identifies the error. 88 | /// 89 | public HttpListenerException (int errorCode) 90 | : base (errorCode) 91 | { 92 | } 93 | 94 | /// 95 | /// Initializes a new instance of the class 96 | /// with the specified and . 97 | /// 98 | /// 99 | /// An that identifies the error. 100 | /// 101 | /// 102 | /// A that describes the error. 103 | /// 104 | public HttpListenerException (int errorCode, string message) 105 | : base (errorCode, message) 106 | { 107 | } 108 | 109 | #endregion 110 | 111 | #region Public Properties 112 | 113 | /// 114 | /// Gets the error code that identifies the error that occurred. 115 | /// 116 | /// 117 | /// An that identifies the error. 118 | /// 119 | public override int ErrorCode { 120 | get { 121 | return NativeErrorCode; 122 | } 123 | } 124 | 125 | #endregion 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpListenerException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac801e71f1eef1149b88beeb1941495f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpListenerPrefixCollection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8f7886e9bea6f624889aafd692f585a5 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpListenerRequest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0558474268fcfc1468cd06f7474139e2 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpListenerResponse.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f651119f4eb5c5409133c5af2f88ee9 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpStatusCode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2cf2595f60c2b248a31746b13f52815 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpStreamAsyncResult.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * HttpStreamAsyncResult.cs 4 | * 5 | * This code is derived from System.Net.HttpStreamAsyncResult.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) 11 | * Copyright (c) 2012-2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Gonzalo Paniagua Javier 37 | */ 38 | #endregion 39 | 40 | using System; 41 | using System.Threading; 42 | 43 | namespace WebSocketSharp.Net 44 | { 45 | internal class HttpStreamAsyncResult : IAsyncResult 46 | { 47 | #region Private Fields 48 | 49 | private AsyncCallback _callback; 50 | private bool _completed; 51 | private object _state; 52 | private object _sync; 53 | private ManualResetEvent _waitHandle; 54 | 55 | #endregion 56 | 57 | #region Internal Fields 58 | 59 | internal byte [] Buffer; 60 | internal int Count; 61 | internal Exception Error; 62 | internal int Offset; 63 | internal int SyncRead; 64 | 65 | #endregion 66 | 67 | #region Public Constructors 68 | 69 | public HttpStreamAsyncResult (AsyncCallback callback, object state) 70 | { 71 | _callback = callback; 72 | _state = state; 73 | _sync = new object (); 74 | } 75 | 76 | #endregion 77 | 78 | #region Public Properties 79 | 80 | public object AsyncState { 81 | get { 82 | return _state; 83 | } 84 | } 85 | 86 | public WaitHandle AsyncWaitHandle { 87 | get { 88 | lock (_sync) 89 | return _waitHandle ?? (_waitHandle = new ManualResetEvent (_completed)); 90 | } 91 | } 92 | 93 | public bool CompletedSynchronously { 94 | get { 95 | return SyncRead == Count; 96 | } 97 | } 98 | 99 | public bool IsCompleted { 100 | get { 101 | lock (_sync) 102 | return _completed; 103 | } 104 | } 105 | 106 | #endregion 107 | 108 | #region Public Methods 109 | 110 | public void Complete () 111 | { 112 | lock (_sync) { 113 | if (_completed) 114 | return; 115 | 116 | _completed = true; 117 | if (_waitHandle != null) 118 | _waitHandle.Set (); 119 | 120 | if (_callback != null) 121 | _callback.BeginInvoke (this, ar => _callback.EndInvoke (ar), null); 122 | } 123 | } 124 | 125 | public void Complete (Exception exception) 126 | { 127 | Error = exception; 128 | Complete (); 129 | } 130 | 131 | #endregion 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpStreamAsyncResult.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b58ef061e9d1d524c855bcbe20e4e2cd 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57be9c00db84b3e46b7aef54ab3d8ea9 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpVersion.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * HttpVersion.cs 4 | * 5 | * This code is derived from System.Net.HttpVersion.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2012-2014 sta.blockhead 11 | * 12 | * Permission is hereby granted, free of charge, to any person obtaining a copy 13 | * of this software and associated documentation files (the "Software"), to deal 14 | * in the Software without restriction, including without limitation the rights 15 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | * copies of the Software, and to permit persons to whom the Software is 17 | * furnished to do so, subject to the following conditions: 18 | * 19 | * The above copyright notice and this permission notice shall be included in 20 | * all copies or substantial portions of the Software. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | * THE SOFTWARE. 29 | */ 30 | #endregion 31 | 32 | #region Authors 33 | /* 34 | * Authors: 35 | * - Lawrence Pit 36 | */ 37 | #endregion 38 | 39 | using System; 40 | 41 | namespace WebSocketSharp.Net 42 | { 43 | /// 44 | /// Provides the HTTP version numbers. 45 | /// 46 | public class HttpVersion 47 | { 48 | #region Public Static Fields 49 | 50 | /// 51 | /// Provides a instance for HTTP 1.0. 52 | /// 53 | public static readonly Version Version10 = new Version (1, 0); 54 | 55 | /// 56 | /// Provides a instance for HTTP 1.1. 57 | /// 58 | public static readonly Version Version11 = new Version (1, 1); 59 | 60 | #endregion 61 | 62 | #region Public Constructors 63 | 64 | /// 65 | /// Initializes a new instance of the class. 66 | /// 67 | public HttpVersion () 68 | { 69 | } 70 | 71 | #endregion 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/HttpVersion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d85bfed4e6c625e4897ed6d6c948a5e0 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/InputChunkState.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * InputChunkState.cs 4 | * 5 | * This code is derived from System.Net.ChunkStream.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2003 Ximian, Inc (http://www.ximian.com) 11 | * Copyright (c) 2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Gonzalo Paniagua Javier 37 | */ 38 | #endregion 39 | 40 | using System; 41 | 42 | namespace WebSocketSharp.Net 43 | { 44 | internal enum InputChunkState 45 | { 46 | None, 47 | Body, 48 | BodyFinished, 49 | Trailer 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/InputChunkState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73a65f8c9aeba4d48b323c877677c0dd 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/InputState.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * InputState.cs 4 | * 5 | * This code is derived from System.Net.HttpConnection.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) 11 | * Copyright (c) 2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Gonzalo Paniagua Javier 37 | */ 38 | #endregion 39 | 40 | using System; 41 | 42 | namespace WebSocketSharp.Net 43 | { 44 | internal enum InputState 45 | { 46 | RequestLine, 47 | Headers 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/InputState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2fc14597a95d5d3489fc8652e6aa12cc 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/LineState.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * LineState.cs 4 | * 5 | * This code is derived from System.Net.HttpConnection.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) 11 | * Copyright (c) 2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Gonzalo Paniagua Javier 37 | */ 38 | #endregion 39 | 40 | using System; 41 | 42 | namespace WebSocketSharp.Net 43 | { 44 | internal enum LineState 45 | { 46 | None, 47 | CR, 48 | LF 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/LineState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f26b5cafcf922bf409ec8509a68895a4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/ListenerAsyncResult.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * ListenerAsyncResult.cs 4 | * 5 | * This code is derived from System.Net.ListenerAsyncResult.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2005 Ximian, Inc. (http://www.ximian.com) 11 | * Copyright (c) 2012-2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Gonzalo Paniagua Javier 37 | */ 38 | #endregion 39 | 40 | using System; 41 | using System.Threading; 42 | 43 | namespace WebSocketSharp.Net 44 | { 45 | internal class ListenerAsyncResult : IAsyncResult 46 | { 47 | #region Private Fields 48 | 49 | private AsyncCallback _callback; 50 | private bool _completed; 51 | private HttpListenerContext _context; 52 | private Exception _exception; 53 | private ManualResetEvent _waitHandle; 54 | private object _state; 55 | private object _sync; 56 | private bool _syncCompleted; 57 | 58 | #endregion 59 | 60 | #region Internal Fields 61 | 62 | internal bool EndCalled; 63 | internal bool InGet; 64 | 65 | #endregion 66 | 67 | #region Public Constructors 68 | 69 | public ListenerAsyncResult (AsyncCallback callback, object state) 70 | { 71 | _callback = callback; 72 | _state = state; 73 | _sync = new object (); 74 | } 75 | 76 | #endregion 77 | 78 | #region Public Properties 79 | 80 | public object AsyncState { 81 | get { 82 | return _state; 83 | } 84 | } 85 | 86 | public WaitHandle AsyncWaitHandle { 87 | get { 88 | lock (_sync) 89 | return _waitHandle ?? (_waitHandle = new ManualResetEvent (_completed)); 90 | } 91 | } 92 | 93 | public bool CompletedSynchronously { 94 | get { 95 | return _syncCompleted; 96 | } 97 | } 98 | 99 | public bool IsCompleted { 100 | get { 101 | lock (_sync) 102 | return _completed; 103 | } 104 | } 105 | 106 | #endregion 107 | 108 | #region Private Methods 109 | 110 | private static void invokeCallback (object state) 111 | { 112 | try { 113 | var ares = (ListenerAsyncResult) state; 114 | ares._callback (ares); 115 | } 116 | catch { 117 | } 118 | } 119 | 120 | #endregion 121 | 122 | #region Internal Methods 123 | 124 | internal void Complete (Exception exception) 125 | { 126 | _exception = InGet && (exception is ObjectDisposedException) 127 | ? new HttpListenerException (500, "Listener closed.") 128 | : exception; 129 | 130 | lock (_sync) { 131 | _completed = true; 132 | if (_waitHandle != null) 133 | _waitHandle.Set (); 134 | 135 | if (_callback != null) 136 | ThreadPool.QueueUserWorkItem(invokeCallback, this); 137 | } 138 | } 139 | 140 | internal void Complete (HttpListenerContext context) 141 | { 142 | Complete (context, false); 143 | } 144 | 145 | internal void Complete (HttpListenerContext context, bool syncCompleted) 146 | { 147 | var listener = context.Listener; 148 | var scheme = listener.SelectAuthenticationScheme (context); 149 | if (scheme == AuthenticationSchemes.None) { 150 | context.Response.Close (HttpStatusCode.Forbidden); 151 | listener.BeginGetContext (this); 152 | 153 | return; 154 | } 155 | 156 | var header = context.Request.Headers ["Authorization"]; 157 | if (scheme == AuthenticationSchemes.Basic && 158 | (header == null || !header.StartsWith ("basic", StringComparison.OrdinalIgnoreCase))) { 159 | context.Response.CloseWithAuthChallenge ( 160 | AuthenticationChallenge.CreateBasicChallenge (listener.Realm).ToBasicString ()); 161 | 162 | listener.BeginGetContext (this); 163 | return; 164 | } 165 | 166 | if (scheme == AuthenticationSchemes.Digest && 167 | (header == null || !header.StartsWith ("digest", StringComparison.OrdinalIgnoreCase))) { 168 | context.Response.CloseWithAuthChallenge ( 169 | AuthenticationChallenge.CreateDigestChallenge (listener.Realm).ToDigestString ()); 170 | 171 | listener.BeginGetContext (this); 172 | return; 173 | } 174 | 175 | _context = context; 176 | _syncCompleted = syncCompleted; 177 | 178 | lock (_sync) { 179 | _completed = true; 180 | if (_waitHandle != null) 181 | _waitHandle.Set (); 182 | 183 | if (_callback != null) 184 | ThreadPool.QueueUserWorkItem(invokeCallback, this); 185 | } 186 | } 187 | 188 | internal HttpListenerContext GetContext () 189 | { 190 | if (_exception != null) 191 | throw _exception; 192 | 193 | return _context; 194 | } 195 | 196 | #endregion 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/ListenerAsyncResult.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e774199d106829e4882dd9cd4606900f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/ListenerPrefix.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * ListenerPrefix.cs 4 | * 5 | * This code is derived from System.Net.ListenerPrefix.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) 11 | * Copyright (c) 2012-2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Gonzalo Paniagua Javier 37 | * - Oleg Mihailik 38 | */ 39 | #endregion 40 | 41 | using System; 42 | using System.Net; 43 | 44 | namespace WebSocketSharp.Net 45 | { 46 | internal sealed class ListenerPrefix 47 | { 48 | #region Private Fields 49 | 50 | IPAddress [] _addresses; 51 | string _host; 52 | string _original; 53 | string _path; 54 | ushort _port; 55 | bool _secure; 56 | 57 | #endregion 58 | 59 | #region Public Fields 60 | 61 | public HttpListener Listener; 62 | 63 | #endregion 64 | 65 | #region Public Constructors 66 | 67 | // Must be called after calling ListenerPrefix.CheckUriPrefix. 68 | public ListenerPrefix (string uriPrefix) 69 | { 70 | _original = uriPrefix; 71 | parse (uriPrefix); 72 | } 73 | 74 | #endregion 75 | 76 | #region Public Properties 77 | 78 | public IPAddress [] Addresses { 79 | get { 80 | return _addresses; 81 | } 82 | 83 | set { 84 | _addresses = value; 85 | } 86 | } 87 | 88 | public string Host { 89 | get { 90 | return _host; 91 | } 92 | } 93 | 94 | public string Path { 95 | get { 96 | return _path; 97 | } 98 | } 99 | 100 | public int Port { 101 | get { 102 | return (int) _port; 103 | } 104 | } 105 | 106 | public bool Secure { 107 | get { 108 | return _secure; 109 | } 110 | } 111 | 112 | #endregion 113 | 114 | #region Private Methods 115 | 116 | private void parse (string uriPrefix) 117 | { 118 | var defaultPort = uriPrefix.StartsWith ("https://") ? 443 : 80; 119 | if (defaultPort == 443) 120 | _secure = true; 121 | 122 | var length = uriPrefix.Length; 123 | var startHost = uriPrefix.IndexOf (':') + 3; 124 | var colon = uriPrefix.IndexOf (':', startHost, length - startHost); 125 | int root; 126 | if (colon > 0) { 127 | root = uriPrefix.IndexOf ('/', colon, length - colon); 128 | _host = uriPrefix.Substring (startHost, colon - startHost); 129 | _port = (ushort) Int32.Parse (uriPrefix.Substring (colon + 1, root - colon - 1)); 130 | _path = uriPrefix.Substring (root); 131 | } 132 | else { 133 | root = uriPrefix.IndexOf ('/', startHost, length - startHost); 134 | _host = uriPrefix.Substring (startHost, root - startHost); 135 | _port = (ushort) defaultPort; 136 | _path = uriPrefix.Substring (root); 137 | } 138 | 139 | if (_path.Length > 1) 140 | _path = _path.Substring (0, _path.Length - 1); 141 | } 142 | 143 | #endregion 144 | 145 | #region public Methods 146 | 147 | public static void CheckUriPrefix (string uriPrefix) 148 | { 149 | if (uriPrefix == null) 150 | throw new ArgumentNullException ("uriPrefix"); 151 | 152 | if (!uriPrefix.StartsWith ("http://") && !uriPrefix.StartsWith ("https://")) 153 | throw new ArgumentException ("Only 'http' and 'https' schemes are supported."); 154 | 155 | var length = uriPrefix.Length; 156 | var startHost = uriPrefix.IndexOf (':') + 3; 157 | if (startHost >= length) 158 | throw new ArgumentException ("No host specified."); 159 | 160 | var colon = uriPrefix.IndexOf (':', startHost, length - startHost); 161 | if (startHost == colon) 162 | throw new ArgumentException ("No host specified."); 163 | 164 | int root; 165 | if (colon > 0) { 166 | root = uriPrefix.IndexOf ('/', colon, length - colon); 167 | if (root == -1) 168 | throw new ArgumentException ("No path specified."); 169 | 170 | int port; 171 | if (!Int32.TryParse (uriPrefix.Substring (colon + 1, root - colon - 1), out port) || 172 | (port <= 0 || port >= 65536)) 173 | throw new ArgumentException ("Invalid port."); 174 | } 175 | else { 176 | root = uriPrefix.IndexOf ('/', startHost, length - startHost); 177 | if (root == -1) 178 | throw new ArgumentException ("No path specified."); 179 | } 180 | 181 | if (uriPrefix [uriPrefix.Length - 1] != '/') 182 | throw new ArgumentException ("The URI prefix must end with '/'."); 183 | } 184 | 185 | // Equals and GetHashCode are required to detect duplicates in HttpListenerPrefixCollection. 186 | public override bool Equals (object obj) 187 | { 188 | var other = obj as ListenerPrefix; 189 | return other != null 190 | ? _original == other._original 191 | : false; 192 | } 193 | 194 | public override int GetHashCode () 195 | { 196 | return _original.GetHashCode (); 197 | } 198 | 199 | public override string ToString () 200 | { 201 | return _original; 202 | } 203 | 204 | #endregion 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/ListenerPrefix.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7ba3d09617a06746ae4f00db5cc7e95 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/NetworkCredential.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * NetworkCredential.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace WebSocketSharp.Net 32 | { 33 | /// 34 | /// Provides the credentials for HTTP authentication (Basic/Digest). 35 | /// 36 | public class NetworkCredential 37 | { 38 | #region Private Fields 39 | 40 | private string _domain; 41 | private string _password; 42 | private string [] _roles; 43 | private string _username; 44 | 45 | #endregion 46 | 47 | #region Public Constructors 48 | 49 | /// 50 | /// Initializes a new instance of the class 51 | /// with the specified user name and password. 52 | /// 53 | /// 54 | /// A that represents the user name associated with the 55 | /// credentials. 56 | /// 57 | /// 58 | /// A that represents the password for the user name 59 | /// associated with the credentials. 60 | /// 61 | /// 62 | /// is or empty. 63 | /// 64 | public NetworkCredential (string username, string password) 65 | : this (username, password, null, new string [0]) 66 | { 67 | } 68 | 69 | /// 70 | /// Initializes a new instance of the class 71 | /// with the specified user name, password, domain, and roles. 72 | /// 73 | /// 74 | /// A that represents the user name associated with the 75 | /// credentials. 76 | /// 77 | /// 78 | /// A that represents the password for the user name 79 | /// associated with the credentials. 80 | /// 81 | /// 82 | /// A that represents the name of the user domain 83 | /// associated with the credentials. 84 | /// 85 | /// 86 | /// An array of that contains the role names to which 87 | /// the user associated with the credentials belongs if any. 88 | /// 89 | /// 90 | /// is or empty. 91 | /// 92 | public NetworkCredential ( 93 | string username, string password, string domain, params string [] roles) 94 | { 95 | if (username == null || username.Length == 0) 96 | throw new ArgumentException ("Must not be null or empty.", "username"); 97 | 98 | _username = username; 99 | _password = password; 100 | _domain = domain; 101 | _roles = roles; 102 | } 103 | 104 | #endregion 105 | 106 | #region Public Properties 107 | 108 | /// 109 | /// Gets the name of the user domain associated with the credentials. 110 | /// 111 | /// 112 | /// A that represents the name of the user domain 113 | /// associated with the credentials. 114 | /// 115 | public string Domain { 116 | get { 117 | return _domain ?? String.Empty; 118 | } 119 | 120 | internal set { 121 | _domain = value; 122 | } 123 | } 124 | 125 | /// 126 | /// Gets the password for the user name associated with the credentials. 127 | /// 128 | /// 129 | /// A that represents the password for the user name 130 | /// associated with the credentials. 131 | /// 132 | public string Password { 133 | get { 134 | return _password ?? String.Empty; 135 | } 136 | 137 | internal set { 138 | _password = value; 139 | } 140 | } 141 | 142 | /// 143 | /// Gets the role names to which the user associated with the credentials 144 | /// belongs. 145 | /// 146 | /// 147 | /// An array of that contains the role names to which 148 | /// the user associated with the credentials belongs. 149 | /// 150 | public string [] Roles { 151 | get { 152 | return _roles; 153 | } 154 | 155 | internal set { 156 | _roles = value; 157 | } 158 | } 159 | 160 | /// 161 | /// Gets the user name associated with the credentials. 162 | /// 163 | /// 164 | /// A that represents the user name associated with the 165 | /// credentials. 166 | /// 167 | public string UserName { 168 | get { 169 | return _username; 170 | } 171 | 172 | internal set { 173 | _username = value; 174 | } 175 | } 176 | 177 | #endregion 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/NetworkCredential.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d072ecd203a1aef479aea006752b87ca 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/QueryStringCollection.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * QueryStringCollection.cs 4 | * 5 | * This code is derived from System.Net.HttpUtility.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2005-2009 Novell, Inc. (http://www.novell.com) 11 | * Copyright (c) 2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Patrik Torstensson 37 | * - Wictor Wilén (decode/encode functions) 38 | * - Tim Coleman 39 | * - Gonzalo Paniagua Javier 40 | */ 41 | #endregion 42 | 43 | using System; 44 | using System.Collections.Specialized; 45 | using System.Text; 46 | 47 | namespace WebSocketSharp.Net 48 | { 49 | internal sealed class QueryStringCollection : NameValueCollection 50 | { 51 | public override string ToString () 52 | { 53 | var cnt = Count; 54 | if (cnt == 0) 55 | return String.Empty; 56 | 57 | var output = new StringBuilder (); 58 | var keys = AllKeys; 59 | foreach (var key in keys) 60 | output.AppendFormat ("{0}={1}&", key, this [key]); 61 | 62 | if (output.Length > 0) 63 | output.Length--; 64 | 65 | return output.ToString (); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/QueryStringCollection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f869b9a24c9507449fd4c9212e6fbe3 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/ReadBufferState.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * ReadBufferState.cs 4 | * 5 | * This code is derived from System.Net.ChunkedInputStream.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com) 11 | * Copyright (c) 2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Gonzalo Paniagua Javier 37 | */ 38 | #endregion 39 | 40 | using System; 41 | 42 | namespace WebSocketSharp.Net 43 | { 44 | internal class ReadBufferState 45 | { 46 | #region Public Constructors 47 | 48 | public ReadBufferState ( 49 | byte [] buffer, int offset, int count, HttpStreamAsyncResult asyncResult) 50 | { 51 | Buffer = buffer; 52 | Offset = offset; 53 | Count = count; 54 | InitialCount = count; 55 | AsyncResult = asyncResult; 56 | } 57 | 58 | #endregion 59 | 60 | #region Public Properties 61 | 62 | public HttpStreamAsyncResult AsyncResult { 63 | get; set; 64 | } 65 | 66 | public byte [] Buffer { 67 | get; set; 68 | } 69 | 70 | public int Count { 71 | get; set; 72 | } 73 | 74 | public int InitialCount { 75 | get; set; 76 | } 77 | 78 | public int Offset { 79 | get; set; 80 | } 81 | 82 | #endregion 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/ReadBufferState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0305b53a1181299409eba30b39680acd 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/RequestStream.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2dc6edc6aff89984592d3bb9f6d3a77f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/ResponseStream.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 255a052cd2e786d46af71dc6682ee21f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/Security.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1033e4d1da2321748a3d9bca6a7eae75 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/Security/SslStream.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * SslStream.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | using System.Net.Security; 31 | using System.Net.Sockets; 32 | 33 | namespace WebSocketSharp.Net.Security 34 | { 35 | internal class SslStream : System.Net.Security.SslStream 36 | { 37 | #region Public Constructors 38 | 39 | public SslStream (NetworkStream innerStream) 40 | : base (innerStream) 41 | { 42 | } 43 | 44 | public SslStream (NetworkStream innerStream, bool leaveInnerStreamOpen) 45 | : base (innerStream, leaveInnerStreamOpen) 46 | { 47 | } 48 | 49 | public SslStream ( 50 | NetworkStream innerStream, 51 | bool leaveInnerStreamOpen, 52 | RemoteCertificateValidationCallback userCertificateValidationCallback) 53 | : base (innerStream, leaveInnerStreamOpen, userCertificateValidationCallback) 54 | { 55 | } 56 | 57 | public SslStream ( 58 | NetworkStream innerStream, 59 | bool leaveInnerStreamOpen, 60 | RemoteCertificateValidationCallback userCertificateValidationCallback, 61 | LocalCertificateSelectionCallback userCertificateSelectionCallback) 62 | : base ( 63 | innerStream, 64 | leaveInnerStreamOpen, 65 | userCertificateValidationCallback, 66 | userCertificateSelectionCallback) 67 | { 68 | } 69 | 70 | #endregion 71 | 72 | #region Public Properties 73 | 74 | public bool DataAvailable { 75 | get { 76 | return ((NetworkStream) InnerStream).DataAvailable; 77 | } 78 | } 79 | 80 | #endregion 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/Security/SslStream.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a77656427ba58c34baaabdfe963157e8 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/WebHeaderCollection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 853e55b214b4f6f4fae0cc6424ec0251 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/WebSockets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa4e1faa5eea0574fbf3f01bdad5ff28 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/WebSockets/HttpListenerWebSocketContext.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6d636d72962f5d44aef6cebbf7e0e7b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/WebSockets/TcpListenerWebSocketContext.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ddb47cc1d0a35ee4494d873de965236e 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Net/WebSockets/WebSocketContext.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d709cd1c9245ca34991b0ae08d86c115 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Opcode.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * Opcode.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace WebSocketSharp 32 | { 33 | /// 34 | /// Contains the values of the opcode that indicates the type of a WebSocket frame. 35 | /// 36 | /// 37 | /// The values of the opcode are defined in 38 | /// Section 5.2 of RFC 6455. 39 | /// 40 | public enum Opcode : byte 41 | { 42 | /// 43 | /// Equivalent to numeric value 0. 44 | /// Indicates a continuation frame. 45 | /// 46 | Cont = 0x0, 47 | /// 48 | /// Equivalent to numeric value 1. 49 | /// Indicates a text frame. 50 | /// 51 | Text = 0x1, 52 | /// 53 | /// Equivalent to numeric value 2. 54 | /// Indicates a binary frame. 55 | /// 56 | Binary = 0x2, 57 | /// 58 | /// Equivalent to numeric value 8. 59 | /// Indicates a connection close frame. 60 | /// 61 | Close = 0x8, 62 | /// 63 | /// Equivalent to numeric value 9. 64 | /// Indicates a ping frame. 65 | /// 66 | Ping = 0x9, 67 | /// 68 | /// Equivalent to numeric value 10. 69 | /// Indicates a pong frame. 70 | /// 71 | Pong = 0xa 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Opcode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08116a1f4132d8d4e828f5348e931f30 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/PayloadData.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * PayloadData.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | using System.Collections; 31 | using System.Collections.Generic; 32 | using System.Text; 33 | 34 | namespace WebSocketSharp 35 | { 36 | internal class PayloadData : IEnumerable 37 | { 38 | #region Private Fields 39 | 40 | private byte [] _applicationData; 41 | private byte [] _extensionData; 42 | private bool _masked; 43 | 44 | #endregion 45 | 46 | #region Public Const Fields 47 | 48 | public const ulong MaxLength = long.MaxValue; 49 | 50 | #endregion 51 | 52 | #region Public Constructors 53 | 54 | public PayloadData () 55 | : this (new byte [0], new byte [0], false) 56 | { 57 | } 58 | 59 | public PayloadData (byte [] applicationData) 60 | : this (new byte [0], applicationData, false) 61 | { 62 | } 63 | 64 | public PayloadData (string applicationData) 65 | : this (new byte [0], Encoding.UTF8.GetBytes (applicationData), false) 66 | { 67 | } 68 | 69 | public PayloadData (byte [] applicationData, bool masked) 70 | : this (new byte [0], applicationData, masked) 71 | { 72 | } 73 | 74 | public PayloadData (byte [] extensionData, byte [] applicationData, bool masked) 75 | { 76 | if ((ulong) extensionData.LongLength + (ulong) applicationData.LongLength > MaxLength) 77 | throw new ArgumentOutOfRangeException ( 78 | "The length of 'extensionData' plus 'applicationData' is greater than MaxLength."); 79 | 80 | _extensionData = extensionData; 81 | _applicationData = applicationData; 82 | _masked = masked; 83 | } 84 | 85 | #endregion 86 | 87 | #region Internal Properties 88 | 89 | internal bool ContainsReservedCloseStatusCode { 90 | get { 91 | return _applicationData.Length > 1 && 92 | _applicationData.SubArray (0, 2).ToUInt16 (ByteOrder.Big).IsReserved (); 93 | } 94 | } 95 | 96 | #endregion 97 | 98 | #region Public Properties 99 | 100 | public byte [] ApplicationData { 101 | get { 102 | return _applicationData; 103 | } 104 | } 105 | 106 | public byte [] ExtensionData { 107 | get { 108 | return _extensionData; 109 | } 110 | } 111 | 112 | public bool IsMasked { 113 | get { 114 | return _masked; 115 | } 116 | } 117 | 118 | public ulong Length { 119 | get { 120 | return (ulong) (_extensionData.LongLength + _applicationData.LongLength); 121 | } 122 | } 123 | 124 | #endregion 125 | 126 | #region Private Methods 127 | 128 | private static void mask (byte [] src, byte [] key) 129 | { 130 | for (long i = 0; i < src.LongLength; i++) 131 | src [i] = (byte) (src [i] ^ key [i % 4]); 132 | } 133 | 134 | #endregion 135 | 136 | #region Public Methods 137 | 138 | public IEnumerator GetEnumerator () 139 | { 140 | foreach (byte b in _extensionData) 141 | yield return b; 142 | 143 | foreach (byte b in _applicationData) 144 | yield return b; 145 | } 146 | 147 | public void Mask (byte [] maskingKey) 148 | { 149 | if (_extensionData.LongLength > 0) 150 | mask (_extensionData, maskingKey); 151 | 152 | if (_applicationData.LongLength > 0) 153 | mask (_applicationData, maskingKey); 154 | 155 | _masked = !_masked; 156 | } 157 | 158 | public byte [] ToByteArray () 159 | { 160 | return _extensionData.LongLength > 0 161 | ? new List (this).ToArray () 162 | : _applicationData; 163 | } 164 | 165 | public override string ToString () 166 | { 167 | return BitConverter.ToString (ToByteArray ()); 168 | } 169 | 170 | #endregion 171 | 172 | #region Explicitly Implemented Interface Members 173 | 174 | IEnumerator IEnumerable.GetEnumerator () 175 | { 176 | return GetEnumerator (); 177 | } 178 | 179 | #endregion 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/PayloadData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ba1c73f5c54ab534e94cb406f218be74 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Rsv.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * Rsv.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace WebSocketSharp 32 | { 33 | internal enum Rsv : byte 34 | { 35 | Off = 0x0, 36 | On = 0x1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/Rsv.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c96f786bb0a34043b18bb4f8110cff9 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/WebSocket.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f809565376eb364d95c7dac01f25a12 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/WebSocketException.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * WebSocketException.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2012-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace WebSocketSharp 32 | { 33 | /// 34 | /// The exception that is thrown when a gets a fatal error. 35 | /// 36 | public class WebSocketException : Exception 37 | { 38 | #region Internal Constructors 39 | 40 | internal WebSocketException () 41 | : this (CloseStatusCode.Abnormal, null, null) 42 | { 43 | } 44 | 45 | internal WebSocketException (string message) 46 | : this (CloseStatusCode.Abnormal, message, null) 47 | { 48 | } 49 | 50 | internal WebSocketException (CloseStatusCode code) 51 | : this (code, null, null) 52 | { 53 | } 54 | 55 | internal WebSocketException (string message, Exception innerException) 56 | : this (CloseStatusCode.Abnormal, message, innerException) 57 | { 58 | } 59 | 60 | internal WebSocketException (CloseStatusCode code, string message) 61 | : this (code, message, null) 62 | { 63 | } 64 | 65 | internal WebSocketException (CloseStatusCode code, string message, Exception innerException) 66 | : base (message ?? code.GetMessage (), innerException) 67 | { 68 | Code = code; 69 | } 70 | 71 | #endregion 72 | 73 | #region Public Properties 74 | 75 | /// 76 | /// Gets the status code indicating the cause for the exception. 77 | /// 78 | /// 79 | /// One of the enum values, represents the status code indicating 80 | /// the cause for the exception. 81 | /// 82 | public CloseStatusCode Code { 83 | get; private set; 84 | } 85 | 86 | #endregion 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/WebSocketException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 144bc914c9257e54b99ea77e6f1714c8 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/WebSocketFrame.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0508f37c785f68b4ebd94c3469b06ff3 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/WebSocketState.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * WebSocketState.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2010-2014 sta.blockhead 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | #endregion 28 | 29 | using System; 30 | 31 | namespace WebSocketSharp 32 | { 33 | /// 34 | /// Contains the values of the state of the WebSocket connection. 35 | /// 36 | /// 37 | /// The values of the state are defined in 38 | /// The WebSocket 39 | /// API. 40 | /// 41 | public enum WebSocketState : ushort 42 | { 43 | /// 44 | /// Equivalent to numeric value 0. 45 | /// Indicates that the connection has not yet been established. 46 | /// 47 | Connecting = 0, 48 | /// 49 | /// Equivalent to numeric value 1. 50 | /// Indicates that the connection is established and the communication is possible. 51 | /// 52 | Open = 1, 53 | /// 54 | /// Equivalent to numeric value 2. 55 | /// Indicates that the connection is going through the closing handshake or 56 | /// the WebSocket.Close method has been invoked. 57 | /// 58 | Closing = 2, 59 | /// 60 | /// Equivalent to numeric value 3. 61 | /// Indicates that the connection has been closed or couldn't be opened. 62 | /// 63 | Closed = 3 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/WebSocketState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 223ae24f299634d45af9039f24d5b03c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/WebSocketStream.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67d631278ca52114f86d5b8b9930a34e 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/websocket-sharp.csproj.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a48c91837bdfc5d46a1486488ea72d5b 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/websocket-sharp.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpanettieri/unity-socket.io-DEPRECATED/98a1abd2909787c467326f843e3344f448b7b3c9/SocketIO/WebsocketSharp/websocket-sharp.snk -------------------------------------------------------------------------------- /SocketIO/WebsocketSharp/websocket-sharp.snk.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bf290fc04cfd7bc4ea70598dec911109 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /SocketIO/readme.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | SocketIO for Unity - v1.0.0 3 | -------------------------------------------------------------------------------- 4 | 5 | # Overview # 6 | 7 | This plugin allows you to integrate your Unity game with Socket.IO back-end 8 | It implements the protocol described at socket.io-protocol github repo. 9 | ( https://github.com/automattic/socket.io-protocol ) 10 | 11 | While connected, Socket.IO run on it's own thread to avoid blocking the main 12 | thread. Events are queued and dispatched on the next frame they are received. 13 | 14 | 15 | # Support # 16 | 17 | fpanettieri@gmail.com 18 | skype: fabio.panettieri 19 | 20 | 21 | # Quick Start # 22 | 23 | In order to start using Socket.IO in your project you need to: 24 | 1. Drag the SocketIO prefab from SocketIO/Prefab/ to your scene. 25 | 2. Configure the url where your Socket.IO server is listening. 26 | 3. Toggle the autoconnect flag if you want it to be always running. 27 | 4. That's it! You can now start using Socket.IO in your game. 28 | 29 | 30 | # How to use # 31 | 32 | 1. Obtaining the Socket.IO component reference 33 | 34 | GameObject go = GameObject.Find("SocketIO"); 35 | socket = go.GetComponent(); 36 | 37 | Bear in mind that using GameObject.Find might be pretty expensive, you 38 | might want to store that reference in a variable for later use. 39 | 40 | 41 | 2. Receiving events 42 | 43 | Using the socket reference you can receive custom events 44 | 45 | public void Start(){ 46 | socket.On("boop", TestBoop); 47 | } 48 | 49 | public void TestBoop(SocketIOEvent e){ 50 | Debug.Log(string.Format("[name: {0}, data: {1}]", e.name, e.data)); 51 | } 52 | 53 | Also, you can also use lambda expresions as callbacks 54 | 55 | socket.On("boop", (SocketIOEvent e) => { 56 | Debug.Log(string.Format("[name: {0}, data: {1}]", e.name, e.data)); 57 | }); 58 | 59 | 60 | 3. Sending events 61 | 62 | Besides listening to Socket.IO events or your custom events, you can 63 | use send information to Socket.IO server using the Emit method. 64 | 65 | a) Sending plain messages 66 | socket.Emit("user:login"); 67 | 68 | b) Sending additional data 69 | 70 | Dictionary data = new Dictionary(); 71 | data["email"] = "some@email.com"; 72 | data["pass"] = Encrypt("1234"); 73 | socket.Emit("user:login", new JSONObject(data)); 74 | 75 | c) Sometimes, you might want to get a callback when the client confirmed 76 | the message reception. To do this, simply pass a function as the last 77 | parameter of .Emit() 78 | 79 | socket.Emit("user:login", OnLogin); 80 | socket.Emit("user:login", new JSONObject(data), OnLogin); 81 | 82 | 83 | 4. Obtaining current socket id (socket.sid) 84 | 85 | public void Start(){ 86 | socket.On("open", OnSocketOpen); 87 | } 88 | 89 | public void OnSocketOpen(SocketIOEvent ev){ 90 | Debug.Log("updated socket id " + socket.sid); 91 | } 92 | 93 | 94 | 5. Namespace Support 95 | Not implemented yet! 96 | 97 | 98 | 6. Binary Events 99 | Not implemented yet! 100 | 101 | 102 | # Examples # 103 | 104 | This package also includes a minimalist test that you might want to use 105 | to verify that you have setup your environment properly. 106 | 107 | 1. Navigate to the server directory 108 | cd PATH/TO/PROJECT/Assets/SocketIO/Server 109 | 110 | 2. Install Socket.IO server package 111 | npm install socket.io 112 | 113 | 3. (Optional) Enable debug mode 114 | Windows: set DEBUG=* 115 | Mac: export DEBUG=* 116 | 117 | 4. Run test server 118 | node ./beep.js 119 | 120 | 5. Open the test scene 121 | SocketIO/Scenes/SocketIOTest 122 | 123 | 6. Run the scene. Some debug message will be printed to Unity console. 124 | 125 | 7. Open SocketIO/Scripts/Test/TestSocketIO.cs to check what's going on. 126 | 127 | 128 | # Troubleshooting # 129 | 130 | This is the first release of the plugin, so error may appear. 131 | In order to track them, I've included some debug code that it's 132 | only compiled when you uncomment some flags. 133 | 134 | In order to enable debug messages you might: 135 | 1. Navigate to SocketIO/Scripts/SocketIO 136 | 2. Open files Decoder.cs, Encoder.cs and SocketIOComponent.cs 137 | 3. Uncomment the following line 138 | #define SOCKET_IO_DEBUG 139 | 4. Run your game again. This time messages sent and received will be 140 | logged to Unity console. Hopefully you might find some lead to the 141 | source of your problems / bugs. 142 | 5. Remember to comment it again after you used it. 143 | 144 | 145 | # License # 146 | 147 | SocketIO for Unity is provided under The MIT License 148 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | DEPRECATED SocketIO for Unity - v1.0.0 3 | -------------------------------------------------------------------------------- 4 | 5 | # Deprecation Notice # 6 | 7 | I haven't used this package in almost 2 years now, the main protocol will 8 | probably work, but I no longer mantain it nor add support for new features. 9 | 10 | # Overview # 11 | 12 | This plugin allows you to integrate your Unity game with Socket.IO back-end 13 | It implements the protocol described at socket.io-protocol github repo. 14 | ( https://github.com/automattic/socket.io-protocol ) 15 | 16 | While connected, Socket.IO run on it's own thread to avoid blocking the main 17 | thread. Events are queued and dispatched on the next frame they are received. 18 | 19 | # Quick Start # 20 | 21 | In order to start using Socket.IO in your project you need to: 22 | 1. Drag the SocketIO prefab from SocketIO/Prefab/ to your scene. 23 | 2. Configure the url where your Socket.IO server is listening. 24 | 3. Toggle the autoconnect flag if you want it to be always running. 25 | 4. That's it! You can now start using Socket.IO in your game. 26 | 27 | 28 | # How to use # 29 | 30 | 1. Obtaining the Socket.IO component reference 31 | 32 | GameObject go = GameObject.Find("SocketIO"); 33 | SocketIOComponent socket = go.GetComponent(); 34 | 35 | Bear in mind that using GameObject.Find might be pretty expensive, you 36 | might want to store that reference in a variable for later use. 37 | 38 | 39 | 2. Receiving events 40 | 41 | Using the socket reference you can receive custom events 42 | 43 | public void Start(){ 44 | socket.On("boop", TestBoop); 45 | } 46 | 47 | public void TestBoop(SocketIOEvent e){ 48 | Debug.Log(string.Format("[name: {0}, data: {1}]", e.name, e.data)); 49 | } 50 | 51 | Also, you can also use lambda expresions as callbacks 52 | 53 | socket.On("boop", (SocketIOEvent e) => { 54 | Debug.Log(string.Format("[name: {0}, data: {1}]", e.name, e.data)); 55 | }); 56 | 57 | 58 | 3. Sending events 59 | 60 | Besides listening to Socket.IO events or your custom events, you can 61 | use send information to Socket.IO server using the Emit method. 62 | 63 | a) Sending plain messages 64 | socket.Emit("user:login"); 65 | 66 | b) Sending additional data 67 | 68 | Dictionary data = new Dictionary(); 69 | data["email"] = "some@email.com"; 70 | data["pass"] = Encrypt("1234"); 71 | socket.Emit("user:login", new JSONObject(data)); 72 | 73 | c) Sometimes, you might want to get a callback when the client confirmed 74 | the message reception. To do this, simply pass a function as the last 75 | parameter of .Emit() 76 | 77 | socket.Emit("user:login", OnLogin); 78 | socket.Emit("user:login", new JSONObject(data), OnLogin); 79 | 80 | 81 | 4. Obtaining current socket id (socket.sid) 82 | 83 | public void Start(){ 84 | socket.On("open", OnSocketOpen); 85 | } 86 | 87 | public void OnSocketOpen(SocketIOEvent ev){ 88 | Debug.Log("updated socket id " + socket.sid); 89 | } 90 | 91 | 92 | 5. Namespace Support 93 | Not implemented yet! 94 | 95 | 96 | 6. Binary Events 97 | Not implemented yet! 98 | 99 | 100 | # Examples # 101 | 102 | This package also includes a minimalist test that you might want to use 103 | to verify that you have setup your environment properly. 104 | 105 | 1. Navigate to the server directory 106 | cd PATH/TO/PROJECT/Assets/SocketIO/Server 107 | 108 | 2. Unzip the server code outside Unity folder 109 | unzip beep.js.zip -d /tmp/socketio 110 | 111 | 3. Go to the destination folder where the server code was extracted 112 | cd /tmp/socketio 113 | 114 | 4. Install Socket.IO server package 115 | npm install socket.io 116 | 117 | 5. (Optional) Enable debug mode 118 | Windows: set DEBUG=* 119 | Mac: export DEBUG=* 120 | 121 | 6. Run test server 122 | node ./beep.js 123 | 124 | 7. Open the test scene 125 | SocketIO/Scenes/SocketIOTest 126 | 127 | 8. Run the scene. Some debug message will be printed to Unity console. 128 | 129 | 9. Open SocketIO/Scripts/Test/TestSocketIO.cs to check what's going on. 130 | 131 | 132 | # Troubleshooting # 133 | 134 | This is the first release of the plugin, so error may appear. 135 | In order to track them, I've included some debug code that it's 136 | only compiled when you uncomment some flags. 137 | 138 | In order to enable debug messages you might: 139 | 1. Navigate to SocketIO/Scripts/SocketIO 140 | 2. Open files Decoder.cs, Encoder.cs and SocketIOComponent.cs 141 | 3. Uncomment the following line 142 | #define SOCKET_IO_DEBUG 143 | 4. Run your game again. This time messages sent and received will be 144 | logged to Unity console. Hopefully you might find some lead to the 145 | source of your problems / bugs. 146 | 5. Remember to comment it again after you used it. 147 | 148 | 149 | # License # 150 | 151 | SocketIO for Unity is provided under The MIT License 152 | --------------------------------------------------------------------------------