Skip to content
This repository has been archived by the owner on Nov 29, 2020. It is now read-only.

Commit

Permalink
Init work on ws server
Browse files Browse the repository at this point in the history
Init work on ws server
  • Loading branch information
N0K0 committed Jan 19, 2020
1 parent f4e83d5 commit c2d1c7a
Show file tree
Hide file tree
Showing 12 changed files with 335 additions and 31 deletions.
8 changes: 8 additions & 0 deletions Assets/Prefabs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

193 changes: 193 additions & 0 deletions Assets/Prefabs/MapController.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7028325030853909456
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7028325030853909469}
- component: {fileID: 7028325030853909467}
- component: {fileID: 7028325030853909468}
- component: {fileID: 7028325030853909470}
- component: {fileID: 7028325030853909471}
m_Layer: 0
m_Name: MapController
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7028325030853909469
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7028325030853909456}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7028325030853909467
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7028325030853909456}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8e5ac92bc18f545cc84cd886ece82b4d, type: 3}
m_Name:
m_EditorClassIdentifier:
editorData:
_bezierPath:
points:
- {x: -2, y: 0, z: 0}
- {x: -2, y: 0, z: 2}
- {x: 2, y: 0, z: 2}
- {x: 2, y: 0, z: 0}
- {x: 2, y: 0, z: -2}
- {x: -2, y: 0, z: -2}
isClosed: 1
space: 0
controlMode: 3
autoControlLength: 0.26
boundsUpToDate: 0
bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 2, y: 0, z: 0}
perAnchorNormalsAngle:
- 0
- 0
globalNormalsAngle: 0
flipNormals: 0
vertexPathUpToDate: 1
vertexPathMaxAngleError: 0.3
vertexPathMinVertexSpacing: 0.01
showTransformTool: 1
showPathBounds: 0
showPerSegmentBounds: 0
displayAnchorPoints: 0
displayControlPoints: 1
bezierHandleScale: 1
globalDisplaySettingsFoldout: 0
keepConstantHandleSize: 0
showNormalsInVertexMode: 0
showBezierPathInVertexMode: 0
showDisplayOptions: 0
showPathOptions: 1
showVertexPathDisplayOptions: 0
showVertexPathOptions: 1
showNormals: 0
showNormalsHelpInfo: 0
tabIndex: 0
initialized: 1
--- !u!114 &7028325030853909468
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7028325030853909456}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9c1b9977f42afdd44bad14ea60694135, type: 3}
m_Name:
m_EditorClassIdentifier:
trackArea: {fileID: 0}
trackPath:
points: []
isClosed: 0
space: 0
controlMode: 0
autoControlLength: 0
boundsUpToDate: 0
bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
perAnchorNormalsAngle: []
globalNormalsAngle: 0
flipNormals: 0
Points_min: 5
Points_max: 10
--- !u!114 &7028325030853909470
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7028325030853909456}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8e5ac92bc18f545cc84cd886ece82b4d, type: 3}
m_Name:
m_EditorClassIdentifier:
editorData:
_bezierPath:
points:
- {x: -2, y: 0, z: 0}
- {x: -1, y: 0, z: 0}
- {x: 1, y: 0, z: 0}
- {x: 2, y: 0, z: 0}
isClosed: 0
space: 1
controlMode: 3
autoControlLength: 0.311
boundsUpToDate: 0
bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 2, y: 0, z: 0}
perAnchorNormalsAngle:
- 0
- 0
globalNormalsAngle: 0
flipNormals: 0
vertexPathUpToDate: 0
vertexPathMaxAngleError: 0
vertexPathMinVertexSpacing: 0
showTransformTool: 1
showPathBounds: 0
showPerSegmentBounds: 0
displayAnchorPoints: 1
displayControlPoints: 1
bezierHandleScale: 1
globalDisplaySettingsFoldout: 0
keepConstantHandleSize: 0
showNormalsInVertexMode: 0
showBezierPathInVertexMode: 0
showDisplayOptions: 1
showPathOptions: 1
showVertexPathDisplayOptions: 0
showVertexPathOptions: 1
showNormals: 1
showNormalsHelpInfo: 0
tabIndex: 0
initialized: 1
--- !u!114 &7028325030853909471
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7028325030853909456}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b275c3b78f8717c4cbc60f74a3247f67, type: 3}
m_Name:
m_EditorClassIdentifier:
pathCreator: {fileID: 7028325030853909467}
autoUpdate: 1
roadWidth: 10
thickness: 0.197
flattenSurface: 1
roadMaterial: {fileID: 2100000, guid: b5df4735192845740bd11076dc9cdc99, type: 2}
undersideMaterial: {fileID: 2100000, guid: c1d8d882244c5344fa86a8fd23246f81, type: 2}
textureTiling: 100
meshHolder: {fileID: 0}
7 changes: 7 additions & 0 deletions Assets/Prefabs/MapController.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions Assets/Prefabs/ServerManager.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &9087444367454905730
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4398040443419906684}
- component: {fileID: 6334292916521052307}
m_Layer: 0
m_Name: ServerManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4398040443419906684
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9087444367454905730}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: -0.0985, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &6334292916521052307
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9087444367454905730}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e22571b7b5c98e74eb44f95b4e01cd86, type: 3}
m_Name:
m_EditorClassIdentifier:
7 changes: 7 additions & 0 deletions Assets/Prefabs/ServerManager.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 39 additions & 3 deletions Assets/Scripts/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,48 @@
using WebSocketSharp;
using WebSocketSharp.Server;

public class Server : MonoBehaviour

public class SocketServer : WebSocketBehavior
{
protected override void OnMessage(MessageEventArgs e)
{
Debug.Log(e.ToString());
}

protected override void OnOpen()
{
Debug.Log("New connection open!");
}

protected override void OnClose(CloseEventArgs e)
{
Debug.Log(e.Reason);
}

protected override void OnError(ErrorEventArgs e)
{
Debug.LogError(e.Message);
}

}

public class Server : MonoBehaviour
{
private SocketServer socketServer;
private WebSocketServer wss;

void Awake()
{
print("test");
WebSocketServer wss = new WebSocketServer("ws://localhost:8888");
wss = new WebSocketServer("ws://localhost:8888");
wss.AddWebSocketService<SocketServer>("/Server");
wss.Start();
}

void Update()
{
if(wss.IsListening)
{
Debug.Log("WSS is Running");
}
}
}
1 change: 1 addition & 0 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"com.unity.collab-proxy": "1.2.16",
"com.unity.package-manager-ui": "2.1.2",
"com.unity.purchasing": "2.0.6",
"com.unity.terrain-tools": "1.1.4-preview",
"com.unity.textmeshpro": "2.0.1",
"com.unity.timeline": "1.0.0",
"com.unity.modules.ai": "1.0.0",
Expand Down
3 changes: 2 additions & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,8 @@ PlayerSettings:
scriptingRuntimeVersion: 1
gcIncremental: 0
gcWBarrierValidation: 0
apiCompatibilityLevelPerPlatform: {}
apiCompatibilityLevelPerPlatform:
Standalone: 3
m_RenderingPath: 1
m_MobileRenderingPath: 1
metroPackageName: Template_3D
Expand Down
Loading

0 comments on commit c2d1c7a

Please sign in to comment.