资源简介
https://blog.csdn.net/nicepainkiller/article/details/80757719
https://blog.csdn.net/nicepainkiller/article/details/80757719
使用说明,Unity3D 中使用 Socket.IO
代码片段和文件信息
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using SocketIO;
using System;
using LitJson;
public class SocketController : MonoBehaviour {
SocketIOComponent socketIO;
private bool login;
private string chatMessage = ““;
private string chatContent = ““;
private string nickName = ““;
private Guid guid = Guid.NewGuid();
// Use this for initialization
void Start ()
{
Gameobject go = Gameobject.Find(“SocketIO“);
if (go == null)
{
go = new Gameobject(“SocketIO“);
socketIO = go.AddComponent();
}
else
{
socketIO = go.GetComponent();
if (socketIO == null)
{
socketIO = go.AddComponent();
}
}
socketIO.url = “ws://192.168.0.170:4567/socket.io/?EIO=3&transport=websocket“;
socketIO.Connect();
OnAddEvemt();
}
private void OnGUI()
{
if (!login)
{
Rect rect = new Rect(Screen.width / 3 Screen.height / 3 Screen.width / 3 Screen.height / 2);
GUI.Box(rect ““ );
GUI.Label(new Rect(rect.x + Screen.width / 60 rect.y + Screen.height / 9 rect.width - Screen.width / 15 Screen.height / 15)“请输入昵称:“);
nickName = GUI.TextField(new Rect(rect.x + Screen.width / 10 rect.y+ Screen.height / 10 rect.width- Screen.width / 5 Screen.height / 15) nickName);
if( GUI.Button(new Rect(rect.x + Screen.width / 30 rect.y + Screen.height/4 rect.width - Screen.width / 15 Screen.height / 15)“登录“ ))
{
if (nickName.Length > 0)
{
Dictionary data = new Dictionary();
data[“guid“] = guid.ToString();
data[“nickName“] = nickName;
socketIO.Emit(SocketIOProtocol.ProtocolLogin new JSONobject(data));
}
}
return;
}
GUI.Label(new Rect(0 0 Screen.width Screen.height - 200) chatContent);
chatMessage = GUI.TextField(new Rect(0 Screen.height - 200 Screen.width - 200 200) chatMessage);
if (GUI.Button(new Rect(Screen.width - 200 Screen.height - 200 200 200) “Send“))
{
Dictionary data = new Dictionary();
data[“chatMessage“] = chatMessage;
socketIO.Emit(SocketIOProtocol.ProtocolChat new JSONobject(data));
chatMessage = string.Empty;
}
}
void OnAddEvemt()
{
socketIO.On(SocketIOProtocol.ProtocolLogin (date) =>
{
JsonData jsonData = JsonMapper.Toobject(date.data.ToStr
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-06-25 16:00 工程\
目录 0 2018-06-25 16:00 工程\Client\
目录 0 2018-06-25 16:00 工程\Client\Unity3D_SocketIO\
目录 0 2018-06-25 16:00 工程\Client\Unity3D_SocketIO\.vs\
目录 0 2018-06-25 16:00 工程\Client\Unity3D_SocketIO\.vs\Unity3D_SocketIO\
目录 0 2018-06-25 16:00 工程\Client\Unity3D_SocketIO\.vs\Unity3D_SocketIO\v15\
文件 288768 2018-06-25 15:47 工程\Client\Unity3D_SocketIO\.vs\Unity3D_SocketIO\v15\.suo
目录 0 2018-06-25 16:00 工程\Client\Unity3D_SocketIO\.vs\Unity3D_SocketIO\v15\Server\
目录 0 2018-06-25 16:00 工程\Client\Unity3D_SocketIO\.vs\Unity3D_SocketIO\v15\Server\sqlite3\
文件 2310144 2018-06-25 15:00 工程\Client\Unity3D_SocketIO\.vs\Unity3D_SocketIO\v15\Server\sqlite3\storage.ide
文件 32768 2018-06-25 10:41 工程\Client\Unity3D_SocketIO\.vs\Unity3D_SocketIO\v15\Server\sqlite3\storage.ide-shm
文件 4152992 2018-06-25 15:00 工程\Client\Unity3D_SocketIO\.vs\Unity3D_SocketIO\v15\Server\sqlite3\storage.ide-wal
目录 0 2018-06-25 16:00 工程\Client\Unity3D_SocketIO\Assets\
文件 7898 2018-06-22 11:35 工程\Client\Unity3D_SocketIO\Assets\CharRoom.unity
文件 196 2018-06-22 10:30 工程\Client\Unity3D_SocketIO\Assets\CharRoom.unity.me
目录 0 2018-06-25 16:00 工程\Client\Unity3D_SocketIO\Assets\Plugins\
文件 51712 2018-04-21 13:05 工程\Client\Unity3D_SocketIO\Assets\Plugins\LitJson.dll
文件 610 2018-06-25 10:46 工程\Client\Unity3D_SocketIO\Assets\Plugins\LitJson.dll.me
文件 213 2018-06-25 10:46 工程\Client\Unity3D_SocketIO\Assets\Plugins.me
目录 0 2018-06-25 16:00 工程\Client\Unity3D_SocketIO\Assets\Socket.IO\
目录 0 2018-06-25 16:00 工程\Client\Unity3D_SocketIO\Assets\Socket.IO\JSONob
目录 0 2018-06-25 16:00 工程\Client\Unity3D_SocketIO\Assets\Socket.IO\JSONob
文件 1339 2016-05-17 20:55 工程\Client\Unity3D_SocketIO\Assets\Socket.IO\JSONob
文件 178 2016-05-17 20:55 工程\Client\Unity3D_SocketIO\Assets\Socket.IO\JSONob
文件 107 2016-05-17 20:55 工程\Client\Unity3D_SocketIO\Assets\Socket.IO\JSONob
文件 27894 2016-05-17 20:55 工程\Client\Unity3D_SocketIO\Assets\Socket.IO\JSONob
文件 178 2016-05-17 20:55 工程\Client\Unity3D_SocketIO\Assets\Socket.IO\JSONob
文件 2854 2016-05-17 20:55 工程\Client\Unity3D_SocketIO\Assets\Socket.IO\JSONob
文件 178 2016-05-17 20:55 工程\Client\Unity3D_SocketIO\Assets\Socket.IO\JSONob
文件 7702 2016-05-17 20:55 工程\Client\Unity3D_SocketIO\Assets\Socket.IO\JSONob
文件 178 2016-05-17 20:55 工程\Client\Unity3D_SocketIO\Assets\Socket.IO\JSONob
............此处省略3428个文件信息
相关资源
- Quantum Computation and Quantum - MICHAEL NIEL
- 安装thermo xcalibur 2.2必须的foundation 2
- WAS9 集群 & IBM HTTP Server 9 部署文档
- 圈圈教你玩USB高清带书签
- HEC-GeoRAS_10.2_Setup
- 鸟哥的Linux私房菜:基础学习篇第四版
- 杭州汇萃智能科技软件说明书HCvisio
- Terrain To Mesh 1.46.unitypackage
- HyperLedger/Fabric Platform-specific Binaries
- Discrete-Event Modeling and Simulation: a prac
- ShareMose 4.0 windows和mac破解版集合
- ABAQUS分析用户手册 卷4——单元卷 A
- Keil uVision4 (MDK)使用帮助_中文完整
- RHCE&RHCSA;题库2018-2019
-
.Actionsc
ript.3.0.Game.Programming.Universi - 4本有用的软件测试书籍英文版打包
- PrinciplesofMathematicalAnalysis(Rudin).pd
- Computer graphics with opengl 4th edition 计算
- Fourier Acoustics Sound Radiation and Nearfiel
- SecureCRT_x86_7.1.1.264_3987绿色版无需安装
- 迅龙数据恢复软件含注册码,免费恢
- qualnet网络仿真软件的学习和
- xilinx ultrascale ddr3控制器 开发手册
- usb大全(中文) Jan Axelson 著
- UserAgent-45184条记录.txt
- Datastead_TVideoGrabber_10.8.4.6_for_Delphi_10
- An Introduction to Number Theory with Cryptogr
- 模式分类Pattern Classification-英文版-第
- Statistics for Spatio-Temporal Data
- Juniper Netscreen SSG140 6.3.0r24固件-2017.6发
评论
共有 条评论