├── README.md ├── ProtoBufServer.rar ├── ProtoBufTool ├── protogen.exe ├── protobuf-net.dll ├── start.bat ├── Inner │ ├── test.proto │ └── SystemProto.proto ├── xml.xslt ├── Output │ ├── test.cs │ └── SystemProto.cs ├── common.xslt ├── csharp.xslt └── vb.xslt ├── Assets ├── Plugins │ ├── protobuf-net.dll │ └── protobuf-net.dll.meta ├── ProtobufTools │ ├── Sample │ │ ├── Sample-1.unity │ │ ├── Sample-2.unity │ │ ├── Sample-1.unity.meta │ │ ├── Sample-2.unity.meta │ │ ├── GameController.cs.meta │ │ ├── UIController.cs.meta │ │ ├── RoomUIController.cs.meta │ │ ├── GameController.cs │ │ ├── UIController.cs │ │ └── RoomUIController.cs │ ├── Prefab │ │ ├── SocketManager.prefab │ │ └── SocketManager.prefab.meta │ ├── Prefab.meta │ ├── Sample.meta │ ├── ProtobufMessage.meta │ ├── ByteBuffer.cs.meta │ ├── EasyLoom.cs.meta │ ├── ByteController.cs.meta │ ├── ClientSocket.cs.meta │ ├── ProtobufTool.cs.meta │ ├── SerializeTool.cs.meta │ ├── SocketManager.cs.meta │ ├── NetworkController.cs.meta │ ├── ProtobufMessage │ │ ├── SystemProto.cs.meta │ │ └── SystemProto.cs │ ├── ProtobufTool.cs │ ├── SerializeTool.cs │ ├── EasyLoom.cs │ ├── SocketManager.cs │ ├── ByteController.cs │ ├── ByteBuffer.cs │ ├── NetworkController.cs │ └── ClientSocket.cs ├── Plugins.meta └── ProtobufTools.meta └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # UnitySocketWithServer 2 | 客户端使用Unity制作Socket网络连接模块,建立简单服务器测试客户端功能,使用Protobuf协议 3 | -------------------------------------------------------------------------------- /ProtoBufServer.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/King098/UnitySocketWithServer/HEAD/ProtoBufServer.rar -------------------------------------------------------------------------------- /ProtoBufTool/protogen.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/King098/UnitySocketWithServer/HEAD/ProtoBufTool/protogen.exe -------------------------------------------------------------------------------- /ProtoBufTool/protobuf-net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/King098/UnitySocketWithServer/HEAD/ProtoBufTool/protobuf-net.dll -------------------------------------------------------------------------------- /Assets/Plugins/protobuf-net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/King098/UnitySocketWithServer/HEAD/Assets/Plugins/protobuf-net.dll -------------------------------------------------------------------------------- /Assets/ProtobufTools/Sample/Sample-1.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/King098/UnitySocketWithServer/HEAD/Assets/ProtobufTools/Sample/Sample-1.unity -------------------------------------------------------------------------------- /Assets/ProtobufTools/Sample/Sample-2.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/King098/UnitySocketWithServer/HEAD/Assets/ProtobufTools/Sample/Sample-2.unity -------------------------------------------------------------------------------- /Assets/ProtobufTools/Prefab/SocketManager.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/King098/UnitySocketWithServer/HEAD/Assets/ProtobufTools/Prefab/SocketManager.prefab -------------------------------------------------------------------------------- /ProtoBufTool/start.bat: -------------------------------------------------------------------------------- 1 | protogen -i:Inner/test.proto -o:Output/test.cs -ns:UGE.Metadata -p:import=UGE 2 | protogen -i:Inner/SystemProto.proto -o:Output/SystemProto.cs -ns:ProtoBuf -------------------------------------------------------------------------------- /Assets/ProtobufTools/Sample/Sample-1.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78c9f6418c8a5154aaa1891be99be2bf 3 | timeCreated: 1489630451 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/Sample/Sample-2.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 10a49314e1a21c34fbc662653044114f 3 | timeCreated: 1489630451 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 685f4adbb675fd44081b48e31494496c 3 | folderAsset: yes 4 | timeCreated: 1489630451 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ProtobufTools.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c83ee6d5c0d7823499a43b01a69a2b7c 3 | folderAsset: yes 4 | timeCreated: 1489630451 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/Prefab/SocketManager.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06b56d8804c04f14bac2099a29cac8d9 3 | timeCreated: 1489630455 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/Prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09dcbb6ebfac3e04bbf4d758d2bda2c8 3 | folderAsset: yes 4 | timeCreated: 1489630451 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/Sample.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 10a2897cce8474b429499a9bcafb9d3f 3 | folderAsset: yes 4 | timeCreated: 1489630451 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/ProtobufMessage.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0b0dc054133fba348b93f9e31b951ac4 3 | folderAsset: yes 4 | timeCreated: 1489630451 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/ByteBuffer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b51079f43e625043aa7a92aedafef52 3 | timeCreated: 1489630453 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/EasyLoom.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4af627d7c75b41243ace1bea45909461 3 | timeCreated: 1489630453 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/ByteController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f85e3905f4f808d42a83c0b689bdd453 3 | timeCreated: 1489651570 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/ClientSocket.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78af4f527a1a8714580757cda06a387a 3 | timeCreated: 1489630453 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/ProtobufTool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f96ceaa2c35406d498ca97e129568163 3 | timeCreated: 1489630453 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/SerializeTool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b13ffa39131c241489a87b843a6dfda1 3 | timeCreated: 1489630453 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/SocketManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e74d7aa17664f94d88bb68e0ef289f2 3 | timeCreated: 1489630453 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/NetworkController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a7ae92ab7f66834fad087b35278e313 3 | timeCreated: 1489630453 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/Sample/GameController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 308c291c63f062145af907665f7b712d 3 | timeCreated: 1489989013 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/Sample/UIController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc52ee16d78b5d648be0d4666bb24ed0 3 | timeCreated: 1489630453 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/Sample/RoomUIController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6050666d0f70774fac9c001dc7cfd1e 3 | timeCreated: 1489979466 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/ProtobufMessage/SystemProto.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8d1a6925aee3f24e88b58b32f7d9841 3 | timeCreated: 1489630453 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /ProtoBufTool/Inner/test.proto: -------------------------------------------------------------------------------- 1 | message TestData { 2 | required int32 ID=1; 3 | required string UserName=2; 4 | required string UserName2=3; 5 | required string UserName3=4; 6 | required string UserName4=5; 7 | required string UserName5=6; 8 | required float value=7; 9 | } 10 | 11 | message TestDataTable 12 | { 13 | repeated TestData data=1; 14 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | 8 | # Autogenerated VS/MD solution and project files 9 | ExportedObj/ 10 | *.csproj 11 | *.unityproj 12 | *.sln 13 | *.suo 14 | *.tmp 15 | *.user 16 | *.userprefs 17 | *.pidb 18 | *.booproj 19 | *.svd 20 | 21 | 22 | # Unity3D generated meta files 23 | *.pidb.meta 24 | 25 | # Unity3D Generated File On Crash Reports 26 | sysinfo.txt 27 | 28 | # Builds 29 | *.apk 30 | *.unitypackage 31 | -------------------------------------------------------------------------------- /Assets/Plugins/protobuf-net.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3aa928bdb0de55c48b5ae6edf4989be3 3 | timeCreated: 1489630452 4 | licenseType: Pro 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | isOverridable: 0 11 | platformData: 12 | Any: 13 | enabled: 1 14 | settings: {} 15 | Editor: 16 | enabled: 0 17 | settings: 18 | DefaultValueInitialized: true 19 | WindowsStoreApps: 20 | enabled: 0 21 | settings: 22 | CPU: AnyCPU 23 | userData: 24 | assetBundleName: 25 | assetBundleVariant: 26 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/Sample/GameController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using ProtoBuf; 6 | 7 | public class GameController 8 | { 9 | private static GameController m_self = null; 10 | public static GameController Instance 11 | { 12 | get 13 | { 14 | if (m_self == null) 15 | { 16 | m_self = new GameController(); 17 | } 18 | return m_self; 19 | } 20 | } 21 | 22 | private GameController() { } 23 | 24 | public PlayerInfo player { get; set; } 25 | } 26 | -------------------------------------------------------------------------------- /ProtoBufTool/xml.xslt: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Xml template for protobuf-net. 13 | 14 | This template writes the proto descriptor as xml. 15 | No options available. 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/ProtobufTool.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System; 3 | 4 | 5 | namespace ProtoBuf 6 | { 7 | public static class ProtobufTool 8 | { 9 | 10 | public static int headLength = sizeof(ushort); 11 | 12 | 13 | public static byte[] CreateData(int typeId,IExtensible pbuf) 14 | { 15 | byte[] pbdata = SerializeTool.Serialize(pbuf); 16 | ByteBuffer buff = new ByteBuffer(); 17 | buff.WriteInt(typeId); 18 | buff.WriteBytes(pbdata); 19 | return WriteMessage(buff.ToBytes()); 20 | } 21 | 22 | public static byte[] WriteMessage(byte[] message) 23 | { 24 | MemoryStream ms = null; 25 | using (ms = new MemoryStream()) 26 | { 27 | ms.Position = 0; 28 | BinaryWriter writer = new BinaryWriter(ms); 29 | ushort msglen = (ushort)message.Length; 30 | writer.Write(msglen); 31 | writer.Write(message); 32 | writer.Flush(); 33 | return ms.ToArray(); 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/ProtobufTools/SerializeTool.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | 4 | namespace ProtoBuf 5 | { 6 | public static class SerializeTool 7 | { 8 | /// 9 | /// 序列化 10 | /// 11 | /// 12 | /// 13 | /// 14 | static public byte[] Serialize(T msg) 15 | { 16 | byte[] result = null; 17 | if (msg != null) 18 | { 19 | using (var stream = new MemoryStream()) 20 | { 21 | Serializer.Serialize(stream, msg); 22 | result = stream.ToArray(); 23 | } 24 | } 25 | return result; 26 | } 27 | 28 | /// 29 | /// 反序列化 30 | /// 31 | /// 32 | /// 33 | /// 34 | static public T Deserialize(byte[] message) 35 | { 36 | T result = default(T); 37 | if (message != null) 38 | { 39 | using (var stream = new MemoryStream(message)) 40 | { 41 | result = Serializer.Deserialize(stream); 42 | } 43 | } 44 | return result; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Assets/ProtobufTools/Sample/UIController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | /// 7 | /// demo类,测试客户端和服务器端的连接测试 8 | /// 9 | public class UIController : MonoBehaviour 10 | { 11 | public InputField username; 12 | public InputField password; 13 | 14 | public GameObject LoginObj; 15 | public GameObject RegisterObj; 16 | 17 | public InputField r_account; 18 | public InputField r_usernamet; 19 | public InputField r_password; 20 | 21 | public bool login; 22 | 23 | private static UIController m_self = null; 24 | public static UIController Instance 25 | { 26 | get 27 | { 28 | return m_self; 29 | } 30 | } 31 | 32 | void Awake() 33 | { 34 | m_self = this; 35 | } 36 | 37 | public void Login() 38 | { 39 | if (SocketManager.Instance != null && SocketManager.Instance.mSocket != null && SocketManager.Instance.mSocket.IsConnected && !login) 40 | { 41 | if (!string.IsNullOrEmpty(username.text) && !string.IsNullOrEmpty(password.text)) 42 | { 43 | NetworkController.RequestLogin(username.text, password.text); 44 | } 45 | } 46 | } 47 | 48 | public void Register() 49 | { 50 | if (SocketManager.Instance != null && SocketManager.Instance.mSocket != null && SocketManager.Instance.mSocket.IsConnected) 51 | { 52 | RegisterObj.SetActive(true); 53 | LoginObj.SetActive(false); 54 | } 55 | } 56 | 57 | public void CancelRegister() 58 | { 59 | RegisterObj.SetActive(false); 60 | LoginObj.SetActive(true); 61 | } 62 | 63 | public void RegisterPlayer() 64 | { 65 | if (SocketManager.Instance != null && SocketManager.Instance.mSocket != null && SocketManager.Instance.mSocket.IsConnected) 66 | { 67 | Debug.Log("注册用户"); 68 | NetworkController.RequestRegister(r_account.text,r_usernamet.text,r_password.text); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/EasyLoom.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using ProtoBuf; 5 | using System; 6 | 7 | public class EasyLoom : MonoBehaviour 8 | { 9 | private static EasyLoom m_self = null; 10 | public static EasyLoom Instance 11 | { 12 | get 13 | { 14 | return m_self; 15 | } 16 | } 17 | 18 | void Awake() 19 | { 20 | m_self = this; 21 | SendList = new List(); 22 | ReceiveList = new List(); 23 | } 24 | 25 | private List SendList; 26 | private List ReceiveList; 27 | private LoomInfo SendTemp; 28 | private LoomInfo ReceiveTemp; 29 | 30 | public void AddSendInfo(LoomInfo info) 31 | { 32 | SendList.Add(info); 33 | } 34 | 35 | public void DeleteSendInfo() 36 | { 37 | SendList.RemoveAt(0); 38 | } 39 | 40 | public void AddReceiveInfo(LoomInfo info) 41 | { 42 | ReceiveList.Add(info); 43 | } 44 | 45 | public void DeleteReceiveInfo() 46 | { 47 | ReceiveList.RemoveAt(0); 48 | } 49 | 50 | 51 | void SendData() 52 | { 53 | if (SendList != null && SendList.Count > 0) 54 | { 55 | SendTemp = SendList[0]; 56 | DeleteSendInfo(); 57 | NetworkController.SendData(SendTemp.proto, SendTemp.data); 58 | } 59 | } 60 | 61 | void ReceiveData() 62 | { 63 | if (ReceiveList != null && ReceiveList.Count > 0) 64 | { 65 | ReceiveTemp = ReceiveList[0]; 66 | DeleteReceiveInfo(); 67 | NetworkController.ReceiveData(ReceiveTemp.proto, ReceiveTemp.data); 68 | } 69 | } 70 | 71 | void Update() 72 | { 73 | if (SocketManager.Instance != null && SocketManager.Instance.mSocket != null && SocketManager.Instance.mSocket.IsConnected) 74 | { 75 | ReceiveData(); 76 | SendData(); 77 | } 78 | } 79 | } 80 | 81 | public class LoomInfo 82 | { 83 | public CmdEnum proto; 84 | public byte[] data; 85 | 86 | public LoomInfo(CmdEnum _proto, byte[] _data) 87 | { 88 | proto = _proto; 89 | data = new byte[_data.Length]; 90 | Array.Copy(_data,0, data, 0, _data.Length); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/SocketManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using ProtoBuf; 5 | 6 | public class SocketManager : MonoBehaviour 7 | { 8 | 9 | private static SocketManager m_self = null; 10 | public static SocketManager Instance 11 | { 12 | get 13 | { 14 | return m_self; 15 | } 16 | } 17 | 18 | void Awake() 19 | { 20 | m_self = this; 21 | DontDestroyOnLoad(this.gameObject); 22 | } 23 | public ClientSocket mSocket; 24 | 25 | public bool connectWhenStart; 26 | public string ip; 27 | public int port; 28 | public int time_out; 29 | 30 | public bool needAliveLink; 31 | public float time_count; 32 | 33 | private float CurTimeCount; 34 | private bool IsAliveLinking; 35 | 36 | 37 | // Use this for initialization 38 | void Start() 39 | { 40 | if (connectWhenStart) 41 | { 42 | ConnectToServer(); 43 | } 44 | } 45 | 46 | /// 47 | /// 连接到服务器的接口 48 | /// 49 | public void ConnectToServer() 50 | { 51 | mSocket = new ClientSocket(); 52 | mSocket.ConnectServer(ip, port, time_out); 53 | } 54 | 55 | public void Reconnect() 56 | { 57 | mSocket.Close(); 58 | ConnectToServer(); 59 | } 60 | 61 | void OnDestory() 62 | { 63 | if (mSocket != null) 64 | { 65 | mSocket.Close(); 66 | } 67 | } 68 | 69 | public void OnConnetTimeOut() 70 | { 71 | //TODO:连接超时处理 72 | } 73 | 74 | public void OnConnectError(string error) 75 | { 76 | //TODO:连接出错处理 77 | } 78 | 79 | public void OnSendError(string error) 80 | { 81 | //TODO:当发送数据出错处理 82 | } 83 | 84 | public void OnReceiveError(string error) 85 | { 86 | //TODO:当接收数据出错处理 87 | Debug.LogWarning("Error:" + error); 88 | } 89 | 90 | //开始一个心跳连接 91 | public void StartAliveLink() 92 | { 93 | if (needAliveLink) 94 | { 95 | CurTimeCount = time_count; 96 | IsAliveLinking = false; 97 | } 98 | } 99 | 100 | void Update() 101 | { 102 | if (needAliveLink && !IsAliveLinking) 103 | { 104 | CurTimeCount -= Time.deltaTime; 105 | if (CurTimeCount <= 0f) 106 | { 107 | IsAliveLinking = true; 108 | CurTimeCount = time_count; 109 | //发送一条连接 110 | NetworkController.RequestAlive(); 111 | } 112 | } 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/ByteController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System; 4 | using System.IO; 5 | 6 | using UnityEngine; 7 | using ProtoBuf; 8 | 9 | /// 10 | /// 字节控制类,一个单例类,用于缓存服务器发过来的所有byte数据,用于解决黏包、分包的问题 11 | /// 12 | public class ByteController 13 | { 14 | private static ByteController m_self = null; 15 | public static ByteController Instance 16 | { 17 | get 18 | { 19 | if (m_self == null) 20 | { 21 | m_self = new ByteController(); 22 | } 23 | return m_self; 24 | } 25 | } 26 | 27 | private ByteController() { } 28 | 29 | private List Datas = new List(); 30 | private ByteBuffer buffer; 31 | 32 | public void AddBytes(byte[] data) 33 | { 34 | //lock (Datas) 35 | { 36 | Datas.AddRange(data); 37 | buffer = ReadBytes(); 38 | while (buffer != null) 39 | { 40 | int datalength = buffer.ReadShort(); 41 | int typeId = buffer.ReadInt(); 42 | byte[] pbdata = buffer.ReadBytes(); 43 | 44 | Debug.Log("接收到新的消息,消息长度为:" + (datalength + sizeof(ushort)) + ";剩余消息长度:" + Datas.Count); 45 | 46 | NetworkController.Receive((CmdEnum)typeId, pbdata); 47 | 48 | buffer = ReadBytes(); 49 | } 50 | } 51 | } 52 | 53 | public ByteBuffer ReadBytes() 54 | { 55 | //lock (Datas) 56 | { 57 | if (Datas.Count <= 0) 58 | return null; 59 | 60 | byte[] b = new byte[ProtobufTool.headLength]; 61 | Array.Copy(Datas.ToArray(), 0, b, 0, b.Length); 62 | int dataLength = (int)BitConverter.ToInt16(b,0); 63 | //reader.Close(); 64 | //取出数据长度段 65 | //byte[] len = BitConverter.GetBytes((ushort)dataLength); 66 | if (Datas.Count >= ProtobufTool.headLength + dataLength) 67 | { 68 | //取出数据段 69 | byte[] data = new byte[ProtobufTool.headLength + dataLength]; 70 | Array.Copy(Datas.ToArray(), 0, data, 0, dataLength + ProtobufTool.headLength); 71 | Datas.RemoveRange(0, ProtobufTool.headLength + dataLength); 72 | 73 | return new ByteBuffer(data); 74 | } 75 | else 76 | { 77 | return null; 78 | } 79 | } 80 | } 81 | 82 | public void UpdateMessage() 83 | { 84 | buffer = ReadBytes(); 85 | if(buffer != null) 86 | { 87 | int datalength = buffer.ReadShort(); 88 | int typeId = buffer.ReadInt(); 89 | byte[] pbdata = buffer.ReadBytes(); 90 | 91 | Debug.Log("接收到新的消息,消息长度为:" + (datalength + sizeof(ushort)) + ";剩余消息长度:" + Datas.Count); 92 | 93 | NetworkController.Receive((CmdEnum)typeId, pbdata); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/Sample/RoomUIController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using ProtoBuf; 5 | using UnityEngine.UI; 6 | 7 | public class RoomUIController : MonoBehaviour 8 | { 9 | private static RoomUIController m_self = null; 10 | public static RoomUIController Instance 11 | { 12 | get 13 | { 14 | return m_self; 15 | } 16 | } 17 | 18 | void Awake() 19 | { 20 | m_self = this; 21 | } 22 | 23 | public VerticalLayoutGroup grid; 24 | public GameObject room; 25 | 26 | public GameObject create_obj; 27 | public InputField roomNameInput; 28 | public Toggle needPasswordToggle; 29 | public InputField passwordInput; 30 | public Toggle canWatchToggle; 31 | public InputField playerNumberInput; 32 | 33 | void Start() 34 | { 35 | NetworkController.RequestGetRooms(); 36 | } 37 | 38 | public void CreateRoomList(List rooms) 39 | { 40 | room.SetActive(false); 41 | ClearChild(grid.gameObject, false); 42 | for (int i = 0; i < rooms.Count; i++) 43 | { 44 | GameObject obj = Instantiate(room) as GameObject; 45 | if (obj != null) 46 | { 47 | Debug.Log("房间号:" + rooms[i].room_id); 48 | obj.transform.SetParent(grid.transform, false); 49 | obj.SetActive(true); 50 | Text t = obj.GetComponentInChildren(); 51 | if(t != null) 52 | { 53 | t.text = t.text.Replace("room_id", rooms[i].room_id.ToString()).Replace("room_name", rooms[i].room_name); 54 | } 55 | obj.name = rooms[i].room_id.ToString(); 56 | } 57 | } 58 | } 59 | 60 | public void ClickPasswrodToggle(bool ison) 61 | { 62 | needPasswordToggle.isOn = ison; 63 | passwordInput.gameObject.SetActive(needPasswordToggle.isOn); 64 | } 65 | 66 | public void ClickCanWatchToggle(bool ison) 67 | { 68 | canWatchToggle.isOn = ison; 69 | playerNumberInput.gameObject.SetActive(canWatchToggle.isOn); 70 | } 71 | 72 | public void ClickCreate() 73 | { 74 | if (roomNameInput.text != "") 75 | { 76 | if (!needPasswordToggle.isOn || passwordInput.text != "") 77 | { 78 | if (!canWatchToggle.isOn || playerNumberInput.text != "") 79 | { 80 | NetworkController.RequestCreateRoom(roomNameInput.text,needPasswordToggle.isOn ? "" : passwordInput.text,canWatchToggle.isOn,int.Parse(playerNumberInput.text)); 81 | } 82 | } 83 | } 84 | } 85 | 86 | public void ClickCancel() 87 | { 88 | create_obj.SetActive(false); 89 | NetworkController.RequestGetRooms(); 90 | } 91 | 92 | public void ClearChild(GameObject parent, bool include_inactive) 93 | { 94 | Transform[] trans = parent.GetComponentsInChildren(include_inactive); 95 | for (int i = 1; i < trans.Length; i++) 96 | { 97 | Destroy(trans[i].gameObject); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /ProtoBufTool/Output/test.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | using UGE; 11 | 12 | // Generated from: Inner/test.proto 13 | namespace UGE.Metadata 14 | { 15 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"TestData")] 16 | public partial class TestData : global::ProtoBuf.IExtensible 17 | { 18 | public TestData() {} 19 | 20 | private int _ID; 21 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"ID", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 22 | public int ID 23 | { 24 | get { return _ID; } 25 | set { _ID = value; } 26 | } 27 | private string _UserName; 28 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"UserName", DataFormat = global::ProtoBuf.DataFormat.Default)] 29 | public string UserName 30 | { 31 | get { return _UserName; } 32 | set { _UserName = value; } 33 | } 34 | private string _UserName2; 35 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"UserName2", DataFormat = global::ProtoBuf.DataFormat.Default)] 36 | public string UserName2 37 | { 38 | get { return _UserName2; } 39 | set { _UserName2 = value; } 40 | } 41 | private string _UserName3; 42 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"UserName3", DataFormat = global::ProtoBuf.DataFormat.Default)] 43 | public string UserName3 44 | { 45 | get { return _UserName3; } 46 | set { _UserName3 = value; } 47 | } 48 | private string _UserName4; 49 | [global::ProtoBuf.ProtoMember(5, IsRequired = true, Name=@"UserName4", DataFormat = global::ProtoBuf.DataFormat.Default)] 50 | public string UserName4 51 | { 52 | get { return _UserName4; } 53 | set { _UserName4 = value; } 54 | } 55 | private string _UserName5; 56 | [global::ProtoBuf.ProtoMember(6, IsRequired = true, Name=@"UserName5", DataFormat = global::ProtoBuf.DataFormat.Default)] 57 | public string UserName5 58 | { 59 | get { return _UserName5; } 60 | set { _UserName5 = value; } 61 | } 62 | private float _value; 63 | [global::ProtoBuf.ProtoMember(7, IsRequired = true, Name=@"value", DataFormat = global::ProtoBuf.DataFormat.FixedSize)] 64 | public float value 65 | { 66 | get { return _value; } 67 | set { _value = value; } 68 | } 69 | private global::ProtoBuf.IExtension extensionObject; 70 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 71 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 72 | } 73 | 74 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"TestDataTable")] 75 | public partial class TestDataTable : global::ProtoBuf.IExtensible 76 | { 77 | public TestDataTable() {} 78 | 79 | private readonly global::System.Collections.Generic.List _data = new global::System.Collections.Generic.List(); 80 | [global::ProtoBuf.ProtoMember(1, Name=@"data", DataFormat = global::ProtoBuf.DataFormat.Default)] 81 | public global::System.Collections.Generic.List data 82 | { 83 | get { return _data; } 84 | } 85 | 86 | private global::ProtoBuf.IExtension extensionObject; 87 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 88 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 89 | } 90 | 91 | } -------------------------------------------------------------------------------- /Assets/ProtobufTools/ByteBuffer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text; 4 | 5 | namespace System 6 | { 7 | public class ByteBuffer 8 | { 9 | MemoryStream stream = null; 10 | BinaryWriter writer = null; 11 | BinaryReader reader = null; 12 | 13 | public ByteBuffer() 14 | { 15 | stream = new MemoryStream(); 16 | writer = new BinaryWriter(stream); 17 | } 18 | 19 | public ByteBuffer(byte[] data) 20 | { 21 | if (data != null) 22 | { 23 | stream = new MemoryStream(data); 24 | reader = new BinaryReader(stream); 25 | } 26 | else 27 | { 28 | stream = new MemoryStream(); 29 | writer = new BinaryWriter(stream); 30 | } 31 | } 32 | 33 | public void Close() 34 | { 35 | if (writer != null) writer.Close(); 36 | if (reader != null) reader.Close(); 37 | 38 | stream.Close(); 39 | writer = null; 40 | reader = null; 41 | stream = null; 42 | } 43 | 44 | public void WriteByte(byte v) 45 | { 46 | writer.Write(v); 47 | } 48 | 49 | public void WriteInt(int v) 50 | { 51 | writer.Write((int)v); 52 | } 53 | 54 | public void WriteShort(ushort v) 55 | { 56 | writer.Write((ushort)v); 57 | } 58 | 59 | public void WriteLong(long v) 60 | { 61 | writer.Write((long)v); 62 | } 63 | 64 | public void WriteFloat(float v) 65 | { 66 | byte[] temp = BitConverter.GetBytes(v); 67 | Array.Reverse(temp); 68 | writer.Write(BitConverter.ToSingle(temp, 0)); 69 | } 70 | 71 | public void WriteDouble(double v) 72 | { 73 | byte[] temp = BitConverter.GetBytes(v); 74 | Array.Reverse(temp); 75 | writer.Write(BitConverter.ToDouble(temp, 0)); 76 | } 77 | 78 | public void WriteString(string v) 79 | { 80 | byte[] bytes = Encoding.UTF8.GetBytes(v); 81 | writer.Write((ushort)bytes.Length); 82 | writer.Write(bytes); 83 | } 84 | 85 | public void WriteBytes(byte[] v) 86 | { 87 | writer.Write((int)v.Length); 88 | writer.Write(v); 89 | } 90 | 91 | public byte ReadByte() 92 | { 93 | return reader.ReadByte(); 94 | } 95 | 96 | public int ReadInt() 97 | { 98 | return (int)reader.ReadInt32(); 99 | } 100 | 101 | public ushort ReadShort() 102 | { 103 | return (ushort)reader.ReadInt16(); 104 | } 105 | 106 | public long ReadLong() 107 | { 108 | return (long)reader.ReadInt64(); 109 | } 110 | 111 | public float ReadFloat() 112 | { 113 | byte[] temp = BitConverter.GetBytes(reader.ReadSingle()); 114 | Array.Reverse(temp); 115 | return BitConverter.ToSingle(temp, 0); 116 | } 117 | 118 | public double ReadDouble() 119 | { 120 | byte[] temp = BitConverter.GetBytes(reader.ReadDouble()); 121 | Array.Reverse(temp); 122 | return BitConverter.ToDouble(temp, 0); 123 | } 124 | 125 | public string ReadString() 126 | { 127 | ushort len = ReadShort(); 128 | byte[] buffer = new byte[len]; 129 | buffer = reader.ReadBytes(len); 130 | return Encoding.UTF8.GetString(buffer); 131 | } 132 | 133 | public byte[] ReadBytes() 134 | { 135 | int len = ReadInt(); 136 | return reader.ReadBytes(len); 137 | } 138 | 139 | public byte[] ToBytes() 140 | { 141 | writer.Flush(); 142 | return stream.ToArray(); 143 | } 144 | 145 | public void Flush() 146 | { 147 | writer.Flush(); 148 | } 149 | } 150 | } -------------------------------------------------------------------------------- /ProtoBufTool/Inner/SystemProto.proto: -------------------------------------------------------------------------------- 1 | enum CmdEnum 2 | { 3 | //客户端心跳请求 4 | Req_Alive = 100000; 5 | //客户端注册请求 6 | Req_Register = 100001; 7 | //客户端登录请求 8 | Req_Login = 100002; 9 | //客户端创建房间请求 10 | Req_CreateRoom = 100003; 11 | //客户端请求房间列表 12 | Req_GetRooms = 100004; 13 | //客户端删除房钱请求 14 | Req_DeleteRoom = 100005; 15 | 16 | 17 | //服务器心跳回复 18 | Res_Alive = 200000; 19 | //服务器返回注册 20 | Res_Register = 200001; 21 | //服务器登录回复 22 | Res_Login = 200002; 23 | //服务器返回创建房间消息 24 | Res_CreateRoom = 200003; 25 | //服务器返回房间列表 26 | Res_GetRooms = 200004; 27 | //服务器删除房间返回 28 | Res_DeleteRoom = 200005; 29 | } 30 | 31 | //客户端发送的心跳消息 32 | message RequestAlive 33 | { 34 | //协议号100000 35 | required int32 proto=1; 36 | } 37 | 38 | //服务器返回心跳记录 39 | message ResponseAlive 40 | { 41 | //协议号200000 42 | required int32 proto=1; 43 | } 44 | 45 | //一个定义的封装消息体 46 | //玩家信息 47 | message PlayerInfo 48 | { 49 | //玩家ID 50 | required string id=1; 51 | //玩家账号 52 | required string account=2; 53 | //玩家用户名 54 | required string username=3; 55 | //玩家密码 56 | required string passwrod=4; 57 | } 58 | 59 | //客户端注册用户请求 60 | message RequestRegister 61 | { 62 | //协议号100001 63 | required int32 proto=1; 64 | //玩家账号 65 | required string account=2; 66 | //用户名 67 | required string username=3; 68 | //密码 69 | required string password=4; 70 | } 71 | 72 | //服务端返回注册用户信息 73 | message ResponseRegister 74 | { 75 | //协议号200001 76 | required int32 proto=1; 77 | //错误信息 78 | optional string error=2; 79 | //用户信息 80 | optional PlayerInfo player_info=3; 81 | } 82 | 83 | //客户端请求登录的消息 84 | message RequestLogin 85 | { 86 | //协议号100002 87 | required int32 proto=1; 88 | //账号 89 | required string account=2; 90 | //密码 91 | required string password=3; 92 | } 93 | 94 | //服务器返回登录消息回复 95 | message ResponseLogin 96 | { 97 | //协议号200002 98 | required int32 proto=1; 99 | //返回错误信息 100 | optional string error=2; 101 | //返回登录消息结果 102 | optional string result=3; 103 | //玩家信息 104 | required PlayerInfo player=4; 105 | } 106 | 107 | //一个定义的封装消息体 108 | //游戏创建的房间信息 109 | message GameRoomInfo 110 | { 111 | //房间号 112 | required string room_id=1; 113 | //房间名称 114 | required string room_name=2; 115 | //房间密码 116 | optional string password=3; 117 | //房间人数上限 118 | optional int32 player_number=4; 119 | //是否允许旁观 120 | optional bool can_watch=5; 121 | //当前房间主人 122 | required string player_id=6; 123 | } 124 | 125 | //客户端请求创建一个新房间 126 | message RequestCreateRoom 127 | { 128 | //协议号100003 129 | required int32 proto=1; 130 | //房间名字 131 | required string room_name=2; 132 | //房间密码 133 | required string password=3; 134 | //是否允许旁观 135 | required bool can_watch=4; 136 | //房间总人数上限 137 | required int32 player_number=5; 138 | //创建房间的玩家ID 139 | required string player_id=6; 140 | } 141 | 142 | //服务器端返回客户端创建的房间信息 143 | message ResponseCreateRoom 144 | { 145 | //协议号200003 146 | required int32 proto=1; 147 | //返回错误信息 148 | optional string error=2; 149 | //返回当前创建成功的房间信息 150 | optional GameRoomInfo room=3; 151 | } 152 | 153 | //客户端请求房间列表的消息 154 | message RequestGetRooms 155 | { 156 | //协议号100004 157 | required int32 proto=1; 158 | } 159 | 160 | //服务器返回所有房间信息 161 | message ResponseGetRooms 162 | { 163 | //协议号200004 164 | required int32 proto=1; 165 | //所有的房间信息 166 | repeated GameRoomInfo rooms=2; 167 | } 168 | 169 | //客户端主动删除一个房间信息 170 | message RequestDeleteRoom 171 | { 172 | //协议号100005 173 | required int32 proto=1; 174 | //房间号 175 | required int32 room_id=2; 176 | //请求消息的玩家ID 177 | required string player_id=3; 178 | } 179 | 180 | //服务器返回删除房间是否成功 181 | message ResponseDeleteRoom 182 | { 183 | //协议号200005 184 | required int32 proto=1; 185 | //删除错误的信息 186 | optional string error=2; 187 | } 188 | 189 | //客户端请求进入一个房间 190 | message RequestJoinRoom 191 | { 192 | //协议号100006 193 | required int32 proto=1; 194 | //请求进入玩家ID 195 | required string player_id=2; 196 | //请求进入的房间ID 197 | required int32 room_id=3; 198 | //房间密码 199 | required string password=4; 200 | //是否是旁观 201 | required bool is_watch=5; 202 | } 203 | 204 | //服务器返回进入房间结果 205 | message ResponseJoinRoom 206 | { 207 | //协议号200006 208 | required int32 proto=1; 209 | //错误消息 210 | required string error=2; 211 | //当前的房间基础信息 212 | required GameRoomInfo room=3; 213 | //当前房间参与游戏的玩家 214 | required string players=4; 215 | //旁观的玩家列表 216 | required string watch_players=5; 217 | } 218 | 219 | //客户端请求离开一个房间的消息 220 | message RequestExitRoom 221 | { 222 | //协议号100007 223 | required int32 proto=1; 224 | //退出房间玩家ID 225 | required string player_id=2; 226 | //要离开的房间ID 227 | required int32 room_id=3; 228 | } 229 | 230 | //服务器返回退出房间消息 231 | message ResponseExitRoom 232 | { 233 | //协议号200007 234 | required int32 proto=1; 235 | //错误消息 236 | required string error=2; 237 | } -------------------------------------------------------------------------------- /ProtoBufTool/common.xslt: -------------------------------------------------------------------------------- 1 | 2 | 5 | 12 | 13 | 14 | Node not handled: / 15 | 16 | ; 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/NetworkController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using ProtoBuf; 5 | using UnityEngine.SceneManagement; 6 | public class NetworkController 7 | { 8 | #region 与服务器数据交互,通过EasyLoom类进行线程间通信 9 | public static void Receive(CmdEnum cmd,byte[] data) 10 | { 11 | EasyLoom.Instance.AddReceiveInfo(new LoomInfo(cmd, data)); 12 | } 13 | 14 | public static void Request(CmdEnum cmd,byte[] data) 15 | { 16 | EasyLoom.Instance.AddSendInfo(new LoomInfo(cmd, data)); 17 | } 18 | #endregion 19 | 20 | 21 | public static void SendData(CmdEnum cmd, byte[] data) 22 | { 23 | SocketManager.Instance.mSocket.SendMessage(data); 24 | } 25 | 26 | public static void ReceiveData(CmdEnum cmd, byte[] data) 27 | { 28 | if (cmd == CmdEnum.Res_Login) 29 | { 30 | ResponseLogin login = SerializeTool.Deserialize(data); 31 | ResponseLogin(login); 32 | } 33 | else if (cmd == CmdEnum.Res_Alive) 34 | { 35 | ResponseAlive alive = SerializeTool.Deserialize(data); 36 | ResponseAlive(alive); 37 | } 38 | else if (cmd == CmdEnum.Res_Register) 39 | { 40 | ResponseRegister response = SerializeTool.Deserialize(data); 41 | ResponseRegister(response); 42 | } 43 | else if (cmd == CmdEnum.Res_CreateRoom) 44 | { 45 | ResponseCreateRoom response = SerializeTool.Deserialize(data); 46 | ResponseCreateRoom(response); 47 | } 48 | else if (cmd == CmdEnum.Res_GetRooms) 49 | { 50 | ResponseGetRooms response = SerializeTool.Deserialize(data); 51 | ResponseGetRooms(response); 52 | } 53 | else if (cmd == CmdEnum.Res_DeleteRoom) 54 | { 55 | ResponseDeleteRoom response = SerializeTool.Deserialize(data); 56 | ResponseDeleteRoom(response); 57 | } 58 | } 59 | 60 | #region 发收消息的具体逻辑处理 61 | 62 | //请求注册 63 | public static void RequestRegister(string account, string username, string password) 64 | { 65 | RequestRegister req = new RequestRegister() 66 | { 67 | proto = (int)CmdEnum.Req_Register, 68 | account = account, 69 | username = username, 70 | password = password 71 | }; 72 | byte[] data = ProtobufTool.CreateData(req.proto, req); 73 | Request((CmdEnum)req.proto, data); 74 | } 75 | 76 | //返回注册 77 | public static void ResponseRegister(ResponseRegister response) 78 | { 79 | if (string.IsNullOrEmpty(response.error)) 80 | { 81 | Debug.Log("注册成功:account" + response.player_info.account); 82 | UIController.Instance.CancelRegister(); 83 | } 84 | } 85 | 86 | //请求登录 87 | public static void RequestLogin(string username, string password) 88 | { 89 | RequestLogin req = new RequestLogin() 90 | { 91 | proto = (int)CmdEnum.Req_Login, 92 | account = username, 93 | password = password 94 | }; 95 | byte[] data = ProtobufTool.CreateData(req.proto, req); 96 | Request((CmdEnum)req.proto, data); 97 | } 98 | 99 | //返回登录 100 | public static void ResponseLogin(ResponseLogin result) 101 | { 102 | #region 测试代码 103 | if(UIController.Instance != null) 104 | { 105 | if (result.error != "") 106 | { 107 | Debug.LogWarning(result.error + result.result); 108 | } 109 | else 110 | { 111 | Debug.Log(result.result); 112 | UIController.Instance.login = true; 113 | GameController.Instance.player = result.player; 114 | SceneManager.LoadScene("sample-2"); 115 | } 116 | } 117 | #endregion 118 | } 119 | 120 | //请求心跳 121 | public static void RequestAlive() 122 | { 123 | RequestAlive req = new RequestAlive() 124 | { 125 | proto = (int)CmdEnum.Req_Alive 126 | }; 127 | byte[] data = ProtobufTool.CreateData(req.proto, req); 128 | Request((CmdEnum)req.proto, data); 129 | } 130 | 131 | //返回心跳 132 | public static void ResponseAlive(ResponseAlive result) 133 | { 134 | SocketManager.Instance.StartAliveLink(); 135 | } 136 | 137 | //请求创建房间 138 | public static void RequestCreateRoom(string room_name,string pass_word,bool can_watch,int count) 139 | { 140 | RequestCreateRoom req = new RequestCreateRoom() 141 | { 142 | proto = (int)CmdEnum.Req_CreateRoom, 143 | room_name = room_name, 144 | password = pass_word, 145 | can_watch = can_watch, 146 | player_number = count, 147 | player_id = GameController.Instance.player.id 148 | }; 149 | byte[] data = ProtobufTool.CreateData(req.proto, req); 150 | Request((CmdEnum)req.proto, data); 151 | } 152 | 153 | //返回创建房间 154 | public static void ResponseCreateRoom(ResponseCreateRoom response) 155 | { 156 | //关闭创建界面,然后再次请求房间列表 157 | RoomUIController.Instance.ClickCancel(); 158 | } 159 | 160 | //请求房间列表 161 | public static void RequestGetRooms() 162 | { 163 | RequestGetRooms req = new RequestGetRooms() 164 | { 165 | proto = (int)CmdEnum.Req_GetRooms 166 | }; 167 | byte[] data = ProtobufTool.CreateData(req.proto, req); 168 | Request((CmdEnum)req.proto, data); 169 | } 170 | 171 | //返回房间列表 172 | public static void ResponseGetRooms(ResponseGetRooms response) 173 | { 174 | if (response != null) 175 | { 176 | RoomUIController.Instance.CreateRoomList(response.rooms); 177 | } 178 | } 179 | 180 | //请求删除房间 181 | public static void RequestDeleteRoom() 182 | { 183 | } 184 | 185 | //返回删除房间 186 | public static void ResponseDeleteRoom(ResponseDeleteRoom response) 187 | { 188 | } 189 | #endregion 190 | } 191 | -------------------------------------------------------------------------------- /Assets/ProtobufTools/ClientSocket.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Net.Sockets; 5 | using System; 6 | using UnityEngine; 7 | using System.Net; 8 | using System.Threading; 9 | 10 | namespace ProtoBuf 11 | { 12 | public class ClientSocket 13 | { 14 | private static byte[] result = new byte[10]; 15 | private static Socket clientSocket; 16 | private Thread receiveThread; 17 | //是否已连接的标识 18 | public bool IsConnected = false; 19 | 20 | public ClientSocket() 21 | { 22 | clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 23 | } 24 | 25 | public void ConnectServer(string ip, int port, int time_out) 26 | { 27 | try 28 | { 29 | IPAddress ipAddress = IPAddress.Parse(ip); 30 | IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, port); 31 | IAsyncResult result = clientSocket.BeginConnect(ipEndPoint, new AsyncCallback(OnConnect), clientSocket); 32 | bool success = result.AsyncWaitHandle.WaitOne(time_out, true); 33 | if (!success)//超时 34 | { 35 | Debug.LogWarning("连接超时"); 36 | clientSocket.Disconnect(true); 37 | //超时处理 38 | SocketManager.Instance.OnConnetTimeOut(); 39 | } 40 | } 41 | catch (Exception e) 42 | { 43 | Debug.LogWarning(e); 44 | //当连接出错处理 45 | SocketManager.Instance.OnConnectError(e.ToString()); 46 | } 47 | } 48 | 49 | void OnConnect(IAsyncResult result) 50 | { 51 | if (result.AsyncState == clientSocket) 52 | { 53 | try 54 | { 55 | clientSocket.EndConnect(result); 56 | IsConnected = true; 57 | 58 | Debug.Log("连接服务器成功"); 59 | 60 | //开始心跳连接 61 | SocketManager.Instance.StartAliveLink(); 62 | 63 | ReceiveSocket(); 64 | } 65 | catch (Exception e) 66 | { 67 | Debug.LogWarning(e); 68 | //当连接出错处理 69 | SocketManager.Instance.OnConnectError(e.ToString()); 70 | } 71 | } 72 | } 73 | 74 | /// 75 | /// 关闭当前的链接 76 | /// 77 | public void Close() 78 | { 79 | if (!IsConnected) 80 | return; 81 | IsConnected = false; 82 | if (receiveThread != null) 83 | { 84 | receiveThread.Abort(); 85 | receiveThread = null; 86 | } 87 | 88 | if (clientSocket != null && clientSocket.Connected) 89 | { 90 | clientSocket.Disconnect(true); 91 | clientSocket.Shutdown(SocketShutdown.Both); 92 | clientSocket.Close(); 93 | clientSocket = null; 94 | } 95 | } 96 | 97 | /// 98 | /// 断线重连 99 | /// 100 | void ReConnect() 101 | { 102 | SocketManager.Instance.Reconnect(); 103 | } 104 | 105 | private void ReceiveSocket() 106 | { 107 | //while (true) 108 | { 109 | if (!clientSocket.Connected) 110 | { 111 | IsConnected = false; 112 | //重连接 113 | ReConnect(); 114 | return; 115 | } 116 | 117 | try 118 | { 119 | clientSocket.BeginReceive(result, 0, result.Length, SocketFlags.None, new AsyncCallback(OnReceive), clientSocket); 120 | } 121 | catch (Exception e) 122 | { 123 | //当连接出错处理 124 | SocketManager.Instance.OnReceiveError(e.ToString()); 125 | clientSocket.Disconnect(true); 126 | clientSocket.Shutdown(SocketShutdown.Both); 127 | clientSocket.Close(); 128 | } 129 | } 130 | } 131 | 132 | void OnReceive(IAsyncResult res) 133 | { 134 | if (res.AsyncState == clientSocket) 135 | { 136 | try 137 | { 138 | int receiveLength = clientSocket.EndReceive(res); 139 | if (receiveLength > 0) 140 | { 141 | //Debug.Log("接收到新的消息,消息长度为:" + receiveLength); 142 | //ByteBuffer buff = new ByteBuffer(result); 143 | //int datalength = buff.ReadShort(); 144 | 145 | byte[] r = new byte[receiveLength]; 146 | Array.Copy(result, 0, r, 0, r.Length); 147 | 148 | //Debug.Log("新消息:" + r.Length); 149 | 150 | ByteController.Instance.AddBytes(r); 151 | 152 | //ByteController.Instance.ReadBytes(); 153 | 154 | //NetworkController.Receive((CmdEnum)typeId, pbdata); 155 | } 156 | //在进行接收数据 157 | ReceiveSocket(); 158 | } 159 | catch (Exception e) 160 | { 161 | //当连接出错处理 162 | SocketManager.Instance.OnReceiveError(e.ToString()); 163 | clientSocket.Disconnect(true); 164 | clientSocket.Shutdown(SocketShutdown.Both); 165 | clientSocket.Close(); 166 | } 167 | } 168 | 169 | } 170 | 171 | 172 | public void SendMessage(byte[] data) 173 | { 174 | if (!clientSocket.Connected) 175 | { 176 | IsConnected = false; 177 | //重连接 178 | ReConnect(); 179 | return; 180 | } 181 | 182 | try 183 | { 184 | clientSocket.BeginSend(data, 0, data.Length, SocketFlags.None, new AsyncCallback(OnSend), clientSocket); 185 | } 186 | catch (Exception e) 187 | { 188 | SocketManager.Instance.OnSendError(e.ToString()); 189 | clientSocket.Disconnect(true); 190 | clientSocket.Shutdown(SocketShutdown.Both); 191 | clientSocket.Close(); 192 | return; 193 | } 194 | } 195 | 196 | 197 | public void OnSend(IAsyncResult result) 198 | { 199 | if (result.AsyncState == clientSocket && IsConnected) 200 | { 201 | try 202 | { 203 | clientSocket.EndSend(result); 204 | } 205 | catch (Exception e) 206 | { 207 | Debug.LogWarning(e); 208 | SocketManager.Instance.OnSendError(e.ToString()); 209 | IsConnected = false; 210 | clientSocket.Shutdown(SocketShutdown.Both); 211 | clientSocket.Close(); 212 | } 213 | } 214 | } 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /ProtoBufTool/Output/SystemProto.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | // Generated from: Inner/SystemProto.proto 11 | namespace ProtoBuf 12 | { 13 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestAlive")] 14 | public partial class RequestAlive : global::ProtoBuf.IExtensible 15 | { 16 | public RequestAlive() {} 17 | 18 | private int _proto; 19 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 20 | public int proto 21 | { 22 | get { return _proto; } 23 | set { _proto = value; } 24 | } 25 | private global::ProtoBuf.IExtension extensionObject; 26 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 27 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 28 | } 29 | 30 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseAlive")] 31 | public partial class ResponseAlive : global::ProtoBuf.IExtensible 32 | { 33 | public ResponseAlive() {} 34 | 35 | private int _proto; 36 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 37 | public int proto 38 | { 39 | get { return _proto; } 40 | set { _proto = value; } 41 | } 42 | private global::ProtoBuf.IExtension extensionObject; 43 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 44 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 45 | } 46 | 47 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"PlayerInfo")] 48 | public partial class PlayerInfo : global::ProtoBuf.IExtensible 49 | { 50 | public PlayerInfo() {} 51 | 52 | private string _id; 53 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"id", DataFormat = global::ProtoBuf.DataFormat.Default)] 54 | public string id 55 | { 56 | get { return _id; } 57 | set { _id = value; } 58 | } 59 | private string _account; 60 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"account", DataFormat = global::ProtoBuf.DataFormat.Default)] 61 | public string account 62 | { 63 | get { return _account; } 64 | set { _account = value; } 65 | } 66 | private string _username; 67 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"username", DataFormat = global::ProtoBuf.DataFormat.Default)] 68 | public string username 69 | { 70 | get { return _username; } 71 | set { _username = value; } 72 | } 73 | private string _passwrod; 74 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"passwrod", DataFormat = global::ProtoBuf.DataFormat.Default)] 75 | public string passwrod 76 | { 77 | get { return _passwrod; } 78 | set { _passwrod = value; } 79 | } 80 | private global::ProtoBuf.IExtension extensionObject; 81 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 82 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 83 | } 84 | 85 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestRegister")] 86 | public partial class RequestRegister : global::ProtoBuf.IExtensible 87 | { 88 | public RequestRegister() {} 89 | 90 | private int _proto; 91 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 92 | public int proto 93 | { 94 | get { return _proto; } 95 | set { _proto = value; } 96 | } 97 | private string _account; 98 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"account", DataFormat = global::ProtoBuf.DataFormat.Default)] 99 | public string account 100 | { 101 | get { return _account; } 102 | set { _account = value; } 103 | } 104 | private string _username; 105 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"username", DataFormat = global::ProtoBuf.DataFormat.Default)] 106 | public string username 107 | { 108 | get { return _username; } 109 | set { _username = value; } 110 | } 111 | private string _password; 112 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"password", DataFormat = global::ProtoBuf.DataFormat.Default)] 113 | public string password 114 | { 115 | get { return _password; } 116 | set { _password = value; } 117 | } 118 | private global::ProtoBuf.IExtension extensionObject; 119 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 120 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 121 | } 122 | 123 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseRegister")] 124 | public partial class ResponseRegister : global::ProtoBuf.IExtensible 125 | { 126 | public ResponseRegister() {} 127 | 128 | private int _proto; 129 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 130 | public int proto 131 | { 132 | get { return _proto; } 133 | set { _proto = value; } 134 | } 135 | private string _error = ""; 136 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)] 137 | [global::System.ComponentModel.DefaultValue("")] 138 | public string error 139 | { 140 | get { return _error; } 141 | set { _error = value; } 142 | } 143 | private PlayerInfo _player_info = null; 144 | [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"player_info", DataFormat = global::ProtoBuf.DataFormat.Default)] 145 | [global::System.ComponentModel.DefaultValue(null)] 146 | public PlayerInfo player_info 147 | { 148 | get { return _player_info; } 149 | set { _player_info = value; } 150 | } 151 | private global::ProtoBuf.IExtension extensionObject; 152 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 153 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 154 | } 155 | 156 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestLogin")] 157 | public partial class RequestLogin : global::ProtoBuf.IExtensible 158 | { 159 | public RequestLogin() {} 160 | 161 | private int _proto; 162 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 163 | public int proto 164 | { 165 | get { return _proto; } 166 | set { _proto = value; } 167 | } 168 | private string _account; 169 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"account", DataFormat = global::ProtoBuf.DataFormat.Default)] 170 | public string account 171 | { 172 | get { return _account; } 173 | set { _account = value; } 174 | } 175 | private string _password; 176 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"password", DataFormat = global::ProtoBuf.DataFormat.Default)] 177 | public string password 178 | { 179 | get { return _password; } 180 | set { _password = value; } 181 | } 182 | private global::ProtoBuf.IExtension extensionObject; 183 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 184 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 185 | } 186 | 187 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseLogin")] 188 | public partial class ResponseLogin : global::ProtoBuf.IExtensible 189 | { 190 | public ResponseLogin() {} 191 | 192 | private int _proto; 193 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 194 | public int proto 195 | { 196 | get { return _proto; } 197 | set { _proto = value; } 198 | } 199 | private string _error = ""; 200 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)] 201 | [global::System.ComponentModel.DefaultValue("")] 202 | public string error 203 | { 204 | get { return _error; } 205 | set { _error = value; } 206 | } 207 | private string _result = ""; 208 | [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"result", DataFormat = global::ProtoBuf.DataFormat.Default)] 209 | [global::System.ComponentModel.DefaultValue("")] 210 | public string result 211 | { 212 | get { return _result; } 213 | set { _result = value; } 214 | } 215 | private PlayerInfo _player; 216 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"player", DataFormat = global::ProtoBuf.DataFormat.Default)] 217 | public PlayerInfo player 218 | { 219 | get { return _player; } 220 | set { _player = value; } 221 | } 222 | private global::ProtoBuf.IExtension extensionObject; 223 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 224 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 225 | } 226 | 227 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"GameRoomInfo")] 228 | public partial class GameRoomInfo : global::ProtoBuf.IExtensible 229 | { 230 | public GameRoomInfo() {} 231 | 232 | private string _room_id; 233 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"room_id", DataFormat = global::ProtoBuf.DataFormat.Default)] 234 | public string room_id 235 | { 236 | get { return _room_id; } 237 | set { _room_id = value; } 238 | } 239 | private string _room_name; 240 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"room_name", DataFormat = global::ProtoBuf.DataFormat.Default)] 241 | public string room_name 242 | { 243 | get { return _room_name; } 244 | set { _room_name = value; } 245 | } 246 | private string _password = ""; 247 | [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"password", DataFormat = global::ProtoBuf.DataFormat.Default)] 248 | [global::System.ComponentModel.DefaultValue("")] 249 | public string password 250 | { 251 | get { return _password; } 252 | set { _password = value; } 253 | } 254 | private int _player_number = default(int); 255 | [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"player_number", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 256 | [global::System.ComponentModel.DefaultValue(default(int))] 257 | public int player_number 258 | { 259 | get { return _player_number; } 260 | set { _player_number = value; } 261 | } 262 | private bool _can_watch = default(bool); 263 | [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"can_watch", DataFormat = global::ProtoBuf.DataFormat.Default)] 264 | [global::System.ComponentModel.DefaultValue(default(bool))] 265 | public bool can_watch 266 | { 267 | get { return _can_watch; } 268 | set { _can_watch = value; } 269 | } 270 | private string _player_id; 271 | [global::ProtoBuf.ProtoMember(6, IsRequired = true, Name=@"player_id", DataFormat = global::ProtoBuf.DataFormat.Default)] 272 | public string player_id 273 | { 274 | get { return _player_id; } 275 | set { _player_id = value; } 276 | } 277 | private global::ProtoBuf.IExtension extensionObject; 278 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 279 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 280 | } 281 | 282 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestCreateRoom")] 283 | public partial class RequestCreateRoom : global::ProtoBuf.IExtensible 284 | { 285 | public RequestCreateRoom() {} 286 | 287 | private int _proto; 288 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 289 | public int proto 290 | { 291 | get { return _proto; } 292 | set { _proto = value; } 293 | } 294 | private string _room_name; 295 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"room_name", DataFormat = global::ProtoBuf.DataFormat.Default)] 296 | public string room_name 297 | { 298 | get { return _room_name; } 299 | set { _room_name = value; } 300 | } 301 | private string _password; 302 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"password", DataFormat = global::ProtoBuf.DataFormat.Default)] 303 | public string password 304 | { 305 | get { return _password; } 306 | set { _password = value; } 307 | } 308 | private bool _can_watch; 309 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"can_watch", DataFormat = global::ProtoBuf.DataFormat.Default)] 310 | public bool can_watch 311 | { 312 | get { return _can_watch; } 313 | set { _can_watch = value; } 314 | } 315 | private int _player_number; 316 | [global::ProtoBuf.ProtoMember(5, IsRequired = true, Name=@"player_number", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 317 | public int player_number 318 | { 319 | get { return _player_number; } 320 | set { _player_number = value; } 321 | } 322 | private string _player_id; 323 | [global::ProtoBuf.ProtoMember(6, IsRequired = true, Name=@"player_id", DataFormat = global::ProtoBuf.DataFormat.Default)] 324 | public string player_id 325 | { 326 | get { return _player_id; } 327 | set { _player_id = value; } 328 | } 329 | private global::ProtoBuf.IExtension extensionObject; 330 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 331 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 332 | } 333 | 334 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseCreateRoom")] 335 | public partial class ResponseCreateRoom : global::ProtoBuf.IExtensible 336 | { 337 | public ResponseCreateRoom() {} 338 | 339 | private int _proto; 340 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 341 | public int proto 342 | { 343 | get { return _proto; } 344 | set { _proto = value; } 345 | } 346 | private string _error = ""; 347 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)] 348 | [global::System.ComponentModel.DefaultValue("")] 349 | public string error 350 | { 351 | get { return _error; } 352 | set { _error = value; } 353 | } 354 | private GameRoomInfo _room = null; 355 | [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"room", DataFormat = global::ProtoBuf.DataFormat.Default)] 356 | [global::System.ComponentModel.DefaultValue(null)] 357 | public GameRoomInfo room 358 | { 359 | get { return _room; } 360 | set { _room = value; } 361 | } 362 | private global::ProtoBuf.IExtension extensionObject; 363 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 364 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 365 | } 366 | 367 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestGetRooms")] 368 | public partial class RequestGetRooms : global::ProtoBuf.IExtensible 369 | { 370 | public RequestGetRooms() {} 371 | 372 | private int _proto; 373 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 374 | public int proto 375 | { 376 | get { return _proto; } 377 | set { _proto = value; } 378 | } 379 | private global::ProtoBuf.IExtension extensionObject; 380 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 381 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 382 | } 383 | 384 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseGetRooms")] 385 | public partial class ResponseGetRooms : global::ProtoBuf.IExtensible 386 | { 387 | public ResponseGetRooms() {} 388 | 389 | private int _proto; 390 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 391 | public int proto 392 | { 393 | get { return _proto; } 394 | set { _proto = value; } 395 | } 396 | private readonly global::System.Collections.Generic.List _rooms = new global::System.Collections.Generic.List(); 397 | [global::ProtoBuf.ProtoMember(2, Name=@"rooms", DataFormat = global::ProtoBuf.DataFormat.Default)] 398 | public global::System.Collections.Generic.List rooms 399 | { 400 | get { return _rooms; } 401 | } 402 | 403 | private global::ProtoBuf.IExtension extensionObject; 404 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 405 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 406 | } 407 | 408 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestDeleteRoom")] 409 | public partial class RequestDeleteRoom : global::ProtoBuf.IExtensible 410 | { 411 | public RequestDeleteRoom() {} 412 | 413 | private int _proto; 414 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 415 | public int proto 416 | { 417 | get { return _proto; } 418 | set { _proto = value; } 419 | } 420 | private int _room_id; 421 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"room_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 422 | public int room_id 423 | { 424 | get { return _room_id; } 425 | set { _room_id = value; } 426 | } 427 | private string _player_id; 428 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"player_id", DataFormat = global::ProtoBuf.DataFormat.Default)] 429 | public string player_id 430 | { 431 | get { return _player_id; } 432 | set { _player_id = value; } 433 | } 434 | private global::ProtoBuf.IExtension extensionObject; 435 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 436 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 437 | } 438 | 439 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseDeleteRoom")] 440 | public partial class ResponseDeleteRoom : global::ProtoBuf.IExtensible 441 | { 442 | public ResponseDeleteRoom() {} 443 | 444 | private int _proto; 445 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 446 | public int proto 447 | { 448 | get { return _proto; } 449 | set { _proto = value; } 450 | } 451 | private string _error = ""; 452 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)] 453 | [global::System.ComponentModel.DefaultValue("")] 454 | public string error 455 | { 456 | get { return _error; } 457 | set { _error = value; } 458 | } 459 | private global::ProtoBuf.IExtension extensionObject; 460 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 461 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 462 | } 463 | 464 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestJoinRoom")] 465 | public partial class RequestJoinRoom : global::ProtoBuf.IExtensible 466 | { 467 | public RequestJoinRoom() {} 468 | 469 | private int _proto; 470 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 471 | public int proto 472 | { 473 | get { return _proto; } 474 | set { _proto = value; } 475 | } 476 | private string _player_id; 477 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"player_id", DataFormat = global::ProtoBuf.DataFormat.Default)] 478 | public string player_id 479 | { 480 | get { return _player_id; } 481 | set { _player_id = value; } 482 | } 483 | private int _room_id; 484 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"room_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 485 | public int room_id 486 | { 487 | get { return _room_id; } 488 | set { _room_id = value; } 489 | } 490 | private string _password; 491 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"password", DataFormat = global::ProtoBuf.DataFormat.Default)] 492 | public string password 493 | { 494 | get { return _password; } 495 | set { _password = value; } 496 | } 497 | private bool _is_watch; 498 | [global::ProtoBuf.ProtoMember(5, IsRequired = true, Name=@"is_watch", DataFormat = global::ProtoBuf.DataFormat.Default)] 499 | public bool is_watch 500 | { 501 | get { return _is_watch; } 502 | set { _is_watch = value; } 503 | } 504 | private global::ProtoBuf.IExtension extensionObject; 505 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 506 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 507 | } 508 | 509 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseJoinRoom")] 510 | public partial class ResponseJoinRoom : global::ProtoBuf.IExtensible 511 | { 512 | public ResponseJoinRoom() {} 513 | 514 | private int _proto; 515 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 516 | public int proto 517 | { 518 | get { return _proto; } 519 | set { _proto = value; } 520 | } 521 | private string _error; 522 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)] 523 | public string error 524 | { 525 | get { return _error; } 526 | set { _error = value; } 527 | } 528 | private GameRoomInfo _room; 529 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"room", DataFormat = global::ProtoBuf.DataFormat.Default)] 530 | public GameRoomInfo room 531 | { 532 | get { return _room; } 533 | set { _room = value; } 534 | } 535 | private string _players; 536 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"players", DataFormat = global::ProtoBuf.DataFormat.Default)] 537 | public string players 538 | { 539 | get { return _players; } 540 | set { _players = value; } 541 | } 542 | private string _watch_players; 543 | [global::ProtoBuf.ProtoMember(5, IsRequired = true, Name=@"watch_players", DataFormat = global::ProtoBuf.DataFormat.Default)] 544 | public string watch_players 545 | { 546 | get { return _watch_players; } 547 | set { _watch_players = value; } 548 | } 549 | private global::ProtoBuf.IExtension extensionObject; 550 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 551 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 552 | } 553 | 554 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestExitRoom")] 555 | public partial class RequestExitRoom : global::ProtoBuf.IExtensible 556 | { 557 | public RequestExitRoom() {} 558 | 559 | private int _proto; 560 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 561 | public int proto 562 | { 563 | get { return _proto; } 564 | set { _proto = value; } 565 | } 566 | private string _player_id; 567 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"player_id", DataFormat = global::ProtoBuf.DataFormat.Default)] 568 | public string player_id 569 | { 570 | get { return _player_id; } 571 | set { _player_id = value; } 572 | } 573 | private int _room_id; 574 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"room_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 575 | public int room_id 576 | { 577 | get { return _room_id; } 578 | set { _room_id = value; } 579 | } 580 | private global::ProtoBuf.IExtension extensionObject; 581 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 582 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 583 | } 584 | 585 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseExitRoom")] 586 | public partial class ResponseExitRoom : global::ProtoBuf.IExtensible 587 | { 588 | public ResponseExitRoom() {} 589 | 590 | private int _proto; 591 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 592 | public int proto 593 | { 594 | get { return _proto; } 595 | set { _proto = value; } 596 | } 597 | private string _error; 598 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)] 599 | public string error 600 | { 601 | get { return _error; } 602 | set { _error = value; } 603 | } 604 | private global::ProtoBuf.IExtension extensionObject; 605 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 606 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 607 | } 608 | 609 | [global::ProtoBuf.ProtoContract(Name=@"CmdEnum")] 610 | public enum CmdEnum 611 | { 612 | 613 | [global::ProtoBuf.ProtoEnum(Name=@"Req_Alive", Value=100000)] 614 | Req_Alive = 100000, 615 | 616 | [global::ProtoBuf.ProtoEnum(Name=@"Req_Register", Value=100001)] 617 | Req_Register = 100001, 618 | 619 | [global::ProtoBuf.ProtoEnum(Name=@"Req_Login", Value=100002)] 620 | Req_Login = 100002, 621 | 622 | [global::ProtoBuf.ProtoEnum(Name=@"Req_CreateRoom", Value=100003)] 623 | Req_CreateRoom = 100003, 624 | 625 | [global::ProtoBuf.ProtoEnum(Name=@"Req_GetRooms", Value=100004)] 626 | Req_GetRooms = 100004, 627 | 628 | [global::ProtoBuf.ProtoEnum(Name=@"Req_DeleteRoom", Value=100005)] 629 | Req_DeleteRoom = 100005, 630 | 631 | [global::ProtoBuf.ProtoEnum(Name=@"Res_Alive", Value=200000)] 632 | Res_Alive = 200000, 633 | 634 | [global::ProtoBuf.ProtoEnum(Name=@"Res_Register", Value=200001)] 635 | Res_Register = 200001, 636 | 637 | [global::ProtoBuf.ProtoEnum(Name=@"Res_Login", Value=200002)] 638 | Res_Login = 200002, 639 | 640 | [global::ProtoBuf.ProtoEnum(Name=@"Res_CreateRoom", Value=200003)] 641 | Res_CreateRoom = 200003, 642 | 643 | [global::ProtoBuf.ProtoEnum(Name=@"Res_GetRooms", Value=200004)] 644 | Res_GetRooms = 200004, 645 | 646 | [global::ProtoBuf.ProtoEnum(Name=@"Res_DeleteRoom", Value=200005)] 647 | Res_DeleteRoom = 200005 648 | } 649 | 650 | } -------------------------------------------------------------------------------- /Assets/ProtobufTools/ProtobufMessage/SystemProto.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | // Generated from: Inner/SystemProto.proto 11 | namespace ProtoBuf 12 | { 13 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestAlive")] 14 | public partial class RequestAlive : global::ProtoBuf.IExtensible 15 | { 16 | public RequestAlive() {} 17 | 18 | private int _proto; 19 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 20 | public int proto 21 | { 22 | get { return _proto; } 23 | set { _proto = value; } 24 | } 25 | private global::ProtoBuf.IExtension extensionObject; 26 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 27 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 28 | } 29 | 30 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseAlive")] 31 | public partial class ResponseAlive : global::ProtoBuf.IExtensible 32 | { 33 | public ResponseAlive() {} 34 | 35 | private int _proto; 36 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 37 | public int proto 38 | { 39 | get { return _proto; } 40 | set { _proto = value; } 41 | } 42 | private global::ProtoBuf.IExtension extensionObject; 43 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 44 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 45 | } 46 | 47 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"PlayerInfo")] 48 | public partial class PlayerInfo : global::ProtoBuf.IExtensible 49 | { 50 | public PlayerInfo() {} 51 | 52 | private string _id; 53 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"id", DataFormat = global::ProtoBuf.DataFormat.Default)] 54 | public string id 55 | { 56 | get { return _id; } 57 | set { _id = value; } 58 | } 59 | private string _account; 60 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"account", DataFormat = global::ProtoBuf.DataFormat.Default)] 61 | public string account 62 | { 63 | get { return _account; } 64 | set { _account = value; } 65 | } 66 | private string _username; 67 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"username", DataFormat = global::ProtoBuf.DataFormat.Default)] 68 | public string username 69 | { 70 | get { return _username; } 71 | set { _username = value; } 72 | } 73 | private string _passwrod; 74 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"passwrod", DataFormat = global::ProtoBuf.DataFormat.Default)] 75 | public string passwrod 76 | { 77 | get { return _passwrod; } 78 | set { _passwrod = value; } 79 | } 80 | private global::ProtoBuf.IExtension extensionObject; 81 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 82 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 83 | } 84 | 85 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestRegister")] 86 | public partial class RequestRegister : global::ProtoBuf.IExtensible 87 | { 88 | public RequestRegister() {} 89 | 90 | private int _proto; 91 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 92 | public int proto 93 | { 94 | get { return _proto; } 95 | set { _proto = value; } 96 | } 97 | private string _account; 98 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"account", DataFormat = global::ProtoBuf.DataFormat.Default)] 99 | public string account 100 | { 101 | get { return _account; } 102 | set { _account = value; } 103 | } 104 | private string _username; 105 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"username", DataFormat = global::ProtoBuf.DataFormat.Default)] 106 | public string username 107 | { 108 | get { return _username; } 109 | set { _username = value; } 110 | } 111 | private string _password; 112 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"password", DataFormat = global::ProtoBuf.DataFormat.Default)] 113 | public string password 114 | { 115 | get { return _password; } 116 | set { _password = value; } 117 | } 118 | private global::ProtoBuf.IExtension extensionObject; 119 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 120 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 121 | } 122 | 123 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseRegister")] 124 | public partial class ResponseRegister : global::ProtoBuf.IExtensible 125 | { 126 | public ResponseRegister() {} 127 | 128 | private int _proto; 129 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 130 | public int proto 131 | { 132 | get { return _proto; } 133 | set { _proto = value; } 134 | } 135 | private string _error = ""; 136 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)] 137 | [global::System.ComponentModel.DefaultValue("")] 138 | public string error 139 | { 140 | get { return _error; } 141 | set { _error = value; } 142 | } 143 | private PlayerInfo _player_info = null; 144 | [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"player_info", DataFormat = global::ProtoBuf.DataFormat.Default)] 145 | [global::System.ComponentModel.DefaultValue(null)] 146 | public PlayerInfo player_info 147 | { 148 | get { return _player_info; } 149 | set { _player_info = value; } 150 | } 151 | private global::ProtoBuf.IExtension extensionObject; 152 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 153 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 154 | } 155 | 156 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestLogin")] 157 | public partial class RequestLogin : global::ProtoBuf.IExtensible 158 | { 159 | public RequestLogin() {} 160 | 161 | private int _proto; 162 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 163 | public int proto 164 | { 165 | get { return _proto; } 166 | set { _proto = value; } 167 | } 168 | private string _account; 169 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"account", DataFormat = global::ProtoBuf.DataFormat.Default)] 170 | public string account 171 | { 172 | get { return _account; } 173 | set { _account = value; } 174 | } 175 | private string _password; 176 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"password", DataFormat = global::ProtoBuf.DataFormat.Default)] 177 | public string password 178 | { 179 | get { return _password; } 180 | set { _password = value; } 181 | } 182 | private global::ProtoBuf.IExtension extensionObject; 183 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 184 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 185 | } 186 | 187 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseLogin")] 188 | public partial class ResponseLogin : global::ProtoBuf.IExtensible 189 | { 190 | public ResponseLogin() {} 191 | 192 | private int _proto; 193 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 194 | public int proto 195 | { 196 | get { return _proto; } 197 | set { _proto = value; } 198 | } 199 | private string _error = ""; 200 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)] 201 | [global::System.ComponentModel.DefaultValue("")] 202 | public string error 203 | { 204 | get { return _error; } 205 | set { _error = value; } 206 | } 207 | private string _result = ""; 208 | [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"result", DataFormat = global::ProtoBuf.DataFormat.Default)] 209 | [global::System.ComponentModel.DefaultValue("")] 210 | public string result 211 | { 212 | get { return _result; } 213 | set { _result = value; } 214 | } 215 | private PlayerInfo _player; 216 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"player", DataFormat = global::ProtoBuf.DataFormat.Default)] 217 | public PlayerInfo player 218 | { 219 | get { return _player; } 220 | set { _player = value; } 221 | } 222 | private global::ProtoBuf.IExtension extensionObject; 223 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 224 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 225 | } 226 | 227 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"GameRoomInfo")] 228 | public partial class GameRoomInfo : global::ProtoBuf.IExtensible 229 | { 230 | public GameRoomInfo() {} 231 | 232 | private string _room_id; 233 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"room_id", DataFormat = global::ProtoBuf.DataFormat.Default)] 234 | public string room_id 235 | { 236 | get { return _room_id; } 237 | set { _room_id = value; } 238 | } 239 | private string _room_name; 240 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"room_name", DataFormat = global::ProtoBuf.DataFormat.Default)] 241 | public string room_name 242 | { 243 | get { return _room_name; } 244 | set { _room_name = value; } 245 | } 246 | private string _password = ""; 247 | [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"password", DataFormat = global::ProtoBuf.DataFormat.Default)] 248 | [global::System.ComponentModel.DefaultValue("")] 249 | public string password 250 | { 251 | get { return _password; } 252 | set { _password = value; } 253 | } 254 | private int _player_number = default(int); 255 | [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"player_number", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 256 | [global::System.ComponentModel.DefaultValue(default(int))] 257 | public int player_number 258 | { 259 | get { return _player_number; } 260 | set { _player_number = value; } 261 | } 262 | private bool _can_watch = default(bool); 263 | [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"can_watch", DataFormat = global::ProtoBuf.DataFormat.Default)] 264 | [global::System.ComponentModel.DefaultValue(default(bool))] 265 | public bool can_watch 266 | { 267 | get { return _can_watch; } 268 | set { _can_watch = value; } 269 | } 270 | private string _player_id; 271 | [global::ProtoBuf.ProtoMember(6, IsRequired = true, Name=@"player_id", DataFormat = global::ProtoBuf.DataFormat.Default)] 272 | public string player_id 273 | { 274 | get { return _player_id; } 275 | set { _player_id = value; } 276 | } 277 | private global::ProtoBuf.IExtension extensionObject; 278 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 279 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 280 | } 281 | 282 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestCreateRoom")] 283 | public partial class RequestCreateRoom : global::ProtoBuf.IExtensible 284 | { 285 | public RequestCreateRoom() {} 286 | 287 | private int _proto; 288 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 289 | public int proto 290 | { 291 | get { return _proto; } 292 | set { _proto = value; } 293 | } 294 | private string _room_name; 295 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"room_name", DataFormat = global::ProtoBuf.DataFormat.Default)] 296 | public string room_name 297 | { 298 | get { return _room_name; } 299 | set { _room_name = value; } 300 | } 301 | private string _password; 302 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"password", DataFormat = global::ProtoBuf.DataFormat.Default)] 303 | public string password 304 | { 305 | get { return _password; } 306 | set { _password = value; } 307 | } 308 | private bool _can_watch; 309 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"can_watch", DataFormat = global::ProtoBuf.DataFormat.Default)] 310 | public bool can_watch 311 | { 312 | get { return _can_watch; } 313 | set { _can_watch = value; } 314 | } 315 | private int _player_number; 316 | [global::ProtoBuf.ProtoMember(5, IsRequired = true, Name=@"player_number", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 317 | public int player_number 318 | { 319 | get { return _player_number; } 320 | set { _player_number = value; } 321 | } 322 | private string _player_id; 323 | [global::ProtoBuf.ProtoMember(6, IsRequired = true, Name=@"player_id", DataFormat = global::ProtoBuf.DataFormat.Default)] 324 | public string player_id 325 | { 326 | get { return _player_id; } 327 | set { _player_id = value; } 328 | } 329 | private global::ProtoBuf.IExtension extensionObject; 330 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 331 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 332 | } 333 | 334 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseCreateRoom")] 335 | public partial class ResponseCreateRoom : global::ProtoBuf.IExtensible 336 | { 337 | public ResponseCreateRoom() {} 338 | 339 | private int _proto; 340 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 341 | public int proto 342 | { 343 | get { return _proto; } 344 | set { _proto = value; } 345 | } 346 | private string _error = ""; 347 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)] 348 | [global::System.ComponentModel.DefaultValue("")] 349 | public string error 350 | { 351 | get { return _error; } 352 | set { _error = value; } 353 | } 354 | private GameRoomInfo _room = null; 355 | [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"room", DataFormat = global::ProtoBuf.DataFormat.Default)] 356 | [global::System.ComponentModel.DefaultValue(null)] 357 | public GameRoomInfo room 358 | { 359 | get { return _room; } 360 | set { _room = value; } 361 | } 362 | private global::ProtoBuf.IExtension extensionObject; 363 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 364 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 365 | } 366 | 367 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestGetRooms")] 368 | public partial class RequestGetRooms : global::ProtoBuf.IExtensible 369 | { 370 | public RequestGetRooms() {} 371 | 372 | private int _proto; 373 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 374 | public int proto 375 | { 376 | get { return _proto; } 377 | set { _proto = value; } 378 | } 379 | private global::ProtoBuf.IExtension extensionObject; 380 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 381 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 382 | } 383 | 384 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseGetRooms")] 385 | public partial class ResponseGetRooms : global::ProtoBuf.IExtensible 386 | { 387 | public ResponseGetRooms() {} 388 | 389 | private int _proto; 390 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 391 | public int proto 392 | { 393 | get { return _proto; } 394 | set { _proto = value; } 395 | } 396 | private readonly global::System.Collections.Generic.List _rooms = new global::System.Collections.Generic.List(); 397 | [global::ProtoBuf.ProtoMember(2, Name=@"rooms", DataFormat = global::ProtoBuf.DataFormat.Default)] 398 | public global::System.Collections.Generic.List rooms 399 | { 400 | get { return _rooms; } 401 | } 402 | 403 | private global::ProtoBuf.IExtension extensionObject; 404 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 405 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 406 | } 407 | 408 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestDeleteRoom")] 409 | public partial class RequestDeleteRoom : global::ProtoBuf.IExtensible 410 | { 411 | public RequestDeleteRoom() {} 412 | 413 | private int _proto; 414 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 415 | public int proto 416 | { 417 | get { return _proto; } 418 | set { _proto = value; } 419 | } 420 | private int _room_id; 421 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"room_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 422 | public int room_id 423 | { 424 | get { return _room_id; } 425 | set { _room_id = value; } 426 | } 427 | private string _player_id; 428 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"player_id", DataFormat = global::ProtoBuf.DataFormat.Default)] 429 | public string player_id 430 | { 431 | get { return _player_id; } 432 | set { _player_id = value; } 433 | } 434 | private global::ProtoBuf.IExtension extensionObject; 435 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 436 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 437 | } 438 | 439 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseDeleteRoom")] 440 | public partial class ResponseDeleteRoom : global::ProtoBuf.IExtensible 441 | { 442 | public ResponseDeleteRoom() {} 443 | 444 | private int _proto; 445 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 446 | public int proto 447 | { 448 | get { return _proto; } 449 | set { _proto = value; } 450 | } 451 | private string _error = ""; 452 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)] 453 | [global::System.ComponentModel.DefaultValue("")] 454 | public string error 455 | { 456 | get { return _error; } 457 | set { _error = value; } 458 | } 459 | private global::ProtoBuf.IExtension extensionObject; 460 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 461 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 462 | } 463 | 464 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestJoinRoom")] 465 | public partial class RequestJoinRoom : global::ProtoBuf.IExtensible 466 | { 467 | public RequestJoinRoom() {} 468 | 469 | private int _proto; 470 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 471 | public int proto 472 | { 473 | get { return _proto; } 474 | set { _proto = value; } 475 | } 476 | private string _player_id; 477 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"player_id", DataFormat = global::ProtoBuf.DataFormat.Default)] 478 | public string player_id 479 | { 480 | get { return _player_id; } 481 | set { _player_id = value; } 482 | } 483 | private int _room_id; 484 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"room_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 485 | public int room_id 486 | { 487 | get { return _room_id; } 488 | set { _room_id = value; } 489 | } 490 | private string _password; 491 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"password", DataFormat = global::ProtoBuf.DataFormat.Default)] 492 | public string password 493 | { 494 | get { return _password; } 495 | set { _password = value; } 496 | } 497 | private bool _is_watch; 498 | [global::ProtoBuf.ProtoMember(5, IsRequired = true, Name=@"is_watch", DataFormat = global::ProtoBuf.DataFormat.Default)] 499 | public bool is_watch 500 | { 501 | get { return _is_watch; } 502 | set { _is_watch = value; } 503 | } 504 | private global::ProtoBuf.IExtension extensionObject; 505 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 506 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 507 | } 508 | 509 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseJoinRoom")] 510 | public partial class ResponseJoinRoom : global::ProtoBuf.IExtensible 511 | { 512 | public ResponseJoinRoom() {} 513 | 514 | private int _proto; 515 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 516 | public int proto 517 | { 518 | get { return _proto; } 519 | set { _proto = value; } 520 | } 521 | private string _error; 522 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)] 523 | public string error 524 | { 525 | get { return _error; } 526 | set { _error = value; } 527 | } 528 | private GameRoomInfo _room; 529 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"room", DataFormat = global::ProtoBuf.DataFormat.Default)] 530 | public GameRoomInfo room 531 | { 532 | get { return _room; } 533 | set { _room = value; } 534 | } 535 | private string _players; 536 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"players", DataFormat = global::ProtoBuf.DataFormat.Default)] 537 | public string players 538 | { 539 | get { return _players; } 540 | set { _players = value; } 541 | } 542 | private string _watch_players; 543 | [global::ProtoBuf.ProtoMember(5, IsRequired = true, Name=@"watch_players", DataFormat = global::ProtoBuf.DataFormat.Default)] 544 | public string watch_players 545 | { 546 | get { return _watch_players; } 547 | set { _watch_players = value; } 548 | } 549 | private global::ProtoBuf.IExtension extensionObject; 550 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 551 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 552 | } 553 | 554 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RequestExitRoom")] 555 | public partial class RequestExitRoom : global::ProtoBuf.IExtensible 556 | { 557 | public RequestExitRoom() {} 558 | 559 | private int _proto; 560 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 561 | public int proto 562 | { 563 | get { return _proto; } 564 | set { _proto = value; } 565 | } 566 | private string _player_id; 567 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"player_id", DataFormat = global::ProtoBuf.DataFormat.Default)] 568 | public string player_id 569 | { 570 | get { return _player_id; } 571 | set { _player_id = value; } 572 | } 573 | private int _room_id; 574 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"room_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 575 | public int room_id 576 | { 577 | get { return _room_id; } 578 | set { _room_id = value; } 579 | } 580 | private global::ProtoBuf.IExtension extensionObject; 581 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 582 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 583 | } 584 | 585 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResponseExitRoom")] 586 | public partial class ResponseExitRoom : global::ProtoBuf.IExtensible 587 | { 588 | public ResponseExitRoom() {} 589 | 590 | private int _proto; 591 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"proto", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 592 | public int proto 593 | { 594 | get { return _proto; } 595 | set { _proto = value; } 596 | } 597 | private string _error; 598 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"error", DataFormat = global::ProtoBuf.DataFormat.Default)] 599 | public string error 600 | { 601 | get { return _error; } 602 | set { _error = value; } 603 | } 604 | private global::ProtoBuf.IExtension extensionObject; 605 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 606 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 607 | } 608 | 609 | [global::ProtoBuf.ProtoContract(Name=@"CmdEnum")] 610 | public enum CmdEnum 611 | { 612 | 613 | [global::ProtoBuf.ProtoEnum(Name=@"Req_Alive", Value=100000)] 614 | Req_Alive = 100000, 615 | 616 | [global::ProtoBuf.ProtoEnum(Name=@"Req_Register", Value=100001)] 617 | Req_Register = 100001, 618 | 619 | [global::ProtoBuf.ProtoEnum(Name=@"Req_Login", Value=100002)] 620 | Req_Login = 100002, 621 | 622 | [global::ProtoBuf.ProtoEnum(Name=@"Req_CreateRoom", Value=100003)] 623 | Req_CreateRoom = 100003, 624 | 625 | [global::ProtoBuf.ProtoEnum(Name=@"Req_GetRooms", Value=100004)] 626 | Req_GetRooms = 100004, 627 | 628 | [global::ProtoBuf.ProtoEnum(Name=@"Req_DeleteRoom", Value=100005)] 629 | Req_DeleteRoom = 100005, 630 | 631 | [global::ProtoBuf.ProtoEnum(Name=@"Res_Alive", Value=200000)] 632 | Res_Alive = 200000, 633 | 634 | [global::ProtoBuf.ProtoEnum(Name=@"Res_Register", Value=200001)] 635 | Res_Register = 200001, 636 | 637 | [global::ProtoBuf.ProtoEnum(Name=@"Res_Login", Value=200002)] 638 | Res_Login = 200002, 639 | 640 | [global::ProtoBuf.ProtoEnum(Name=@"Res_CreateRoom", Value=200003)] 641 | Res_CreateRoom = 200003, 642 | 643 | [global::ProtoBuf.ProtoEnum(Name=@"Res_GetRooms", Value=200004)] 644 | Res_GetRooms = 200004, 645 | 646 | [global::ProtoBuf.ProtoEnum(Name=@"Res_DeleteRoom", Value=200005)] 647 | Res_DeleteRoom = 200005 648 | } 649 | 650 | } -------------------------------------------------------------------------------- /ProtoBufTool/csharp.xslt: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | //------------------------------------------------------------------------------ 39 | // <auto-generated> 40 | // This code was generated by a tool. 41 | // 42 | // Changes to this file may cause incorrect behavior and will be lost if 43 | // the code is regenerated. 44 | // </auto-generated> 45 | //------------------------------------------------------------------------------ 46 | 49 | 50 | 51 | 52 | 53 | 54 | using ; 56 | 57 | 58 | 59 | 60 | using ; 61 | 62 | 63 | 64 | 65 | 66 | 67 | CSharp template for protobuf-net. 68 | Options: 69 | General: 70 | "help" - this page 71 | Additional serializer support: 72 | "xml" - enable explicit xml support (XmlSerializer) 73 | "datacontract" - enable data-contract support (DataContractSerializer; requires .NET 3.0) 74 | "binary" - enable binary support (BinaryFormatter; not supported on Silverlight) 75 | Other: 76 | "protoRpc" - enable proto-rpc client 77 | "observable" - change notification (observer pattern) support 78 | "preObservable" - pre-change notification (observer pattern) support (requires .NET 3.5) 79 | "partialMethods" - provide partial methods for changes (requires C# 3.0) 80 | "detectMissing" - provide *Specified properties to indicate whether fields are present 81 | "lightFramework" - omit additional attributes not included in CF/Silverlight 82 | "asynchronous" - emit asynchronous methods for use with WCF 83 | "clientProxy" - emit asynchronous client proxy class 84 | "import" - additional namespaces to import (semicolon delimited) 85 | "fixCase" - change type/member names (types/properties become PascalCase; fields become camelCase) 86 | 87 | 88 | 89 | 90 | 91 | Invalid options: xml and data-contract serialization are mutually exclusive. 92 | 93 | 94 | 95 | // Option: xml serialization ([XmlType]/[XmlElement]) enabled 96 | 97 | // Option: data-contract serialization ([DataContract]/[DataMember]) enabled 98 | 99 | // Option: binary serialization (ISerializable) enabled 100 | 101 | // Option: observable (OnPropertyChanged) enabled 102 | 103 | // Option: pre-observable (OnPropertyChanging) enabled 104 | 105 | // Option: partial methods (On*Changing/On*Changed) enabled 106 | 107 | // Option: missing-value detection (*Specified/ShouldSerialize*/Reset*) enabled 108 | 109 | // Option: light framework (CF/Silverlight) enabled 110 | 111 | // Option: proto-rpc enabled 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | // Generated from: 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | namespace 130 | { 131 | 132 | 133 | } 134 | 135 | 136 | // Note: requires additional types generated from: 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"")] 153 | [global::System.Runtime.Serialization.DataContract(Name=@"")] 154 | [global::System.Xml.Serialization.XmlType(TypeName=@"")] 155 | public partial class : global::ProtoBuf.IExtensible, global::System.Runtime.Serialization.ISerializable, global::System.ComponentModel.INotifyPropertyChanged, global::System.ComponentModel.INotifyPropertyChanging 160 | { 161 | public () {} 162 | 163 | protected (global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) 164 | : this() { global::ProtoBuf.Serializer.Merge(info, this); } 165 | void global::System.Runtime.Serialization.ISerializable.GetObjectData(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) 166 | { global::ProtoBuf.Serializer.Serialize(info, this); } 167 | 168 | public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; 169 | protected virtual void OnPropertyChanged(string propertyName) 170 | { if(PropertyChanged != null) PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(propertyName)); } 171 | 172 | public event global::System.ComponentModel.PropertyChangingEventHandler PropertyChanging; 173 | protected virtual void OnPropertyChanging(string propertyName) 174 | { if(PropertyChanging != null) PropertyChanging(this, new global::System.ComponentModel.PropertyChangingEventArgs(propertyName)); } 175 | 176 | private global::ProtoBuf.IExtension extensionObject; 177 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 178 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 179 | } 180 | 181 | 182 | 183 | 184 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | [global::ProtoBuf.ProtoContract(Name=@"")] 199 | [global::System.Runtime.Serialization.DataContract(Name=@"")] 200 | 201 | [global::System.Xml.Serialization.XmlType(TypeName=@"")] 202 | public enum 204 | { 205 | 206 | } 207 | 208 | 209 | 210 | 211 | 212 | 0 213 | 214 | [global::ProtoBuf.ProtoEnum(Name=@"", Value=)] 216 | [global::System.Runtime.Serialization.EnumMember(Value=@"")] 218 | [global::System.Xml.Serialization.XmlEnum(@"")] 220 | = , 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | @ 243 | 244 | |abstract|as|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|do|double|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|goto|if|implicit|in|int|interface|internal|is|lock|long|namespace|new|null|object|operator|out|override|params|private|protected|public|readonly|ref|return|sbyte|sealed|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|virtual|void|volatile|while| 245 | 246 | 247 | 248 | FixedSize 251 | Group 252 | TwosComplement 255 | ZigZag 256 | Default 257 | 258 | 259 | 260 | 261 | struct 262 | struct 263 | struct 264 | struct 265 | struct 266 | struct 267 | struct 268 | struct 269 | struct 270 | class 271 | class 272 | struct 273 | struct 274 | struct 275 | struct 276 | struct 277 | struct 278 | none 279 | 280 | 281 | Field type not implemented: (.) 282 | 283 | 284 | 285 | 286 | 287 | 288 | double 289 | double 290 | float 291 | long 292 | ulong 293 | int 294 | ulong 295 | uint 296 | bool 297 | string 298 | byte[] 299 | uint 300 | int 301 | long 302 | int 303 | long 304 | 305 | 306 | 307 | 308 | 309 | Field type not implemented: (.) 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | @"" 319 | . 320 | 321 | 322 | /* 323 | 324 | */ null 325 | () 326 | 327 | 328 | 329 | 337 | 338 | 339 | 340 | 341 | . 342 | . 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | "" 353 | null 354 | null 355 | . 356 | default() 357 | 358 | 359 | 360 | global::System.Obsolete, 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | ? 371 | private = ; 372 | [global::ProtoBuf.ProtoMember(, IsRequired = false, Name=@"", DataFormat = global::ProtoBuf.DataFormat.)] 374 | [global::System.ComponentModel.DefaultValue()] 376 | [global::System.Xml.Serialization.XmlElement(@"", Order = )] 377 | 378 | [global::System.Runtime.Serialization.DataMember(Name=@"", Order = , IsRequired = false)] 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | private ; 394 | [global::ProtoBuf.ProtoMember(, IsRequired = true, Name=@"", DataFormat = global::ProtoBuf.DataFormat.)] 396 | [global::System.Xml.Serialization.XmlElement(@"", Order = )] 397 | 398 | [global::System.Runtime.Serialization.DataMember(Name=@"", Order = , IsRequired = true)] 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | public 427 | { 428 | get { return ; } 429 | set { OnChanging(value); OnPropertyChanging(@""); = value; OnPropertyChanged(@""); OnChanged();} 430 | } 431 | partial void OnChanging( value); 432 | partial void OnChanged(); 433 | [global::System.Xml.Serialization.XmlIgnore] 434 | [global::System.ComponentModel.Browsable(false)] 435 | public bool Specified 436 | { 437 | get { return this. != null; } 438 | set { if (value == (this.== null)) this. = value ? this. : ()null; } 439 | } 440 | private bool ShouldSerialize() { return Specified; } 441 | private void Reset() { Specified = false; } 442 | 443 | 444 | 445 | 446 | 447 | 448 | private readonly global::System.Collections.Generic.List<> = new global::System.Collections.Generic.List<>(); 449 | [global::ProtoBuf.ProtoMember(, Name=@"", DataFormat = global::ProtoBuf.DataFormat., Options = global::ProtoBuf.MemberSerializationOptions.Packed)] 451 | [global::System.Runtime.Serialization.DataMember(Name=@"", Order = , IsRequired = false)] 452 | 453 | [global::System.Xml.Serialization.XmlElement(@"", Order = )] 454 | 455 | public global::System.Collections.Generic.List<> 456 | { 457 | get { return ; } 459 | set { = value; } 460 | } 461 | 462 | 463 | 464 | 465 | [global::System.ServiceModel.ServiceContract(Name = @"")] 466 | public interface I 467 | { 468 | 469 | } 470 | 471 | 472 | public class Client : global::ProtoBuf.ServiceModel.RpcClient 473 | { 474 | public Client() : base(typeof(I)) { } 475 | 476 | } 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | [global::System.ServiceModel.OperationContract(Name = @"")] 485 | [global::ProtoBuf.ServiceModel.ProtoBehavior] 486 | 487 | ( request); 488 | 489 | [global::System.ServiceModel.OperationContract(AsyncPattern = true, Name = @"")] 490 | global::System.IAsyncResult Begin( request, global::System.AsyncCallback callback, object state); 491 | End(global::System.IAsyncResult ar); 492 | 493 | 494 | 495 | 496 | ( request) 497 | { 498 | return () Send(@"", request); 499 | } 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | public partial class CompletedEventArgs : global::System.ComponentModel.AsyncCompletedEventArgs 509 | { 510 | private object[] results; 511 | 512 | public CompletedEventArgs(object[] results, global::System.Exception exception, bool cancelled, object userState) 513 | : base(exception, cancelled, userState) 514 | { 515 | this.results = results; 516 | } 517 | 518 | public Result 519 | { 520 | get { 521 | base.RaiseExceptionIfNecessary(); 522 | return ()(this.results[0]); 523 | } 524 | } 525 | } 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | [global::System.Diagnostics.DebuggerStepThroughAttribute()] 534 | public partial class Client : global::System.ServiceModel.ClientBase<I>, I 535 | { 536 | 537 | public Client() 538 | {} 539 | public Client(string endpointConfigurationName) 540 | : base(endpointConfigurationName) 541 | {} 542 | public Client(string endpointConfigurationName, string remoteAddress) 543 | : base(endpointConfigurationName, remoteAddress) 544 | {} 545 | public Client(string endpointConfigurationName, global::System.ServiceModel.EndpointAddress remoteAddress) 546 | : base(endpointConfigurationName, remoteAddress) 547 | {} 548 | public Client(global::System.ServiceModel.Channels.Binding binding, global::System.ServiceModel.EndpointAddress remoteAddress) 549 | : base(binding, remoteAddress) 550 | {} 551 | 552 | 553 | } 554 | 555 | 556 | 557 | 558 | 559 | private BeginOperationDelegate onBeginDelegate; 560 | private EndOperationDelegate onEndDelegate; 561 | private global::System.Threading.SendOrPostCallback onCompletedDelegate; 562 | 563 | public event global::System.EventHandler<CompletedEventArgs> Completed; 564 | 565 | public ( request) 566 | { 567 | return base.Channel.(request); 568 | } 569 | 570 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 571 | public global::System.IAsyncResult Begin( request, global::System.AsyncCallback callback, object asyncState) 572 | { 573 | return base.Channel.Begin(request, callback, asyncState); 574 | } 575 | 576 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 577 | public End(global::System.IAsyncResult result) 578 | { 579 | return base.Channel.End(result); 580 | } 581 | 582 | private global::System.IAsyncResult OnBegin(object[] inValues, global::System.AsyncCallback callback, object asyncState) 583 | { 584 | request = (()(inValues[0])); 585 | return this.Begin(request, callback, asyncState); 586 | } 587 | 588 | private object[] OnEnd(global::System.IAsyncResult result) 589 | { 590 | retVal = this.End(result); 591 | return new object[] { 592 | retVal}; 593 | } 594 | 595 | private void OnCompleted(object state) 596 | { 597 | if ((this.Completed != null)) 598 | { 599 | InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state)); 600 | this.Completed(this, new CompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState)); 601 | } 602 | } 603 | 604 | public void Async( request) 605 | { 606 | this.Async(request, null); 607 | } 608 | 609 | public void Async( request, object userState) 610 | { 611 | if ((this.onBeginDelegate == null)) 612 | { 613 | this.onBeginDelegate = new BeginOperationDelegate(this.OnBegin); 614 | } 615 | if ((this.onEndDelegate == null)) 616 | { 617 | this.onEndDelegate = new EndOperationDelegate(this.OnEnd); 618 | } 619 | if ((this.onCompletedDelegate == null)) 620 | { 621 | this.onCompletedDelegate = new global::System.Threading.SendOrPostCallback(this.OnCompleted); 622 | } 623 | base.InvokeAsync(this.onBeginDelegate, new object[] { 624 | request}, this.onEndDelegate, this.onCompletedDelegate, userState); 625 | } 626 | 627 | 628 | 629 | -------------------------------------------------------------------------------- /ProtoBufTool/vb.xslt: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | VisualBasic template for protobuf-net. 43 | Options: 44 | General: 45 | "help" - this page 46 | Additional serializer support: 47 | "xml" - enable explicit xml support (XmlSerializer) 48 | "datacontract" - enable data-contract support (DataContractSerializer; requires .NET 3.0) 49 | "binary" - enable binary support (BinaryFormatter; not supported on Silverlight) 50 | Other: 51 | "protoRpc" - enable proto-rpc client 52 | "observable" - change notification (observer pattern) support 53 | "preObservable" - pre-change notification (observer pattern) support (requires .NET 3.5) 54 | "partialMethods" - provide partial methods for changes (requires C# 3.0) 55 | "detectMissing" - provide *Specified properties to indicate whether fields are present 56 | "lightFramework" - omit additional attributes not included in CF/Silverlight 57 | "asynchronous" - emit asynchronous methods for use with WCF 58 | "clientProxy" - emit asynchronous client proxy class 59 | 60 | 61 | 62 | 63 | 64 | Invalid options: xml and data-contract serialization are mutually exclusive. 65 | 66 | 67 | ' Generated from 68 | 69 | ' Option: xml serialization ([XmlType]/[XmlElement]) enabled 70 | 71 | ' Option: data-contract serialization ([DataContract]/[DataMember]) enabled 72 | 73 | ' Option: binary serialization (ISerializable) enabled 74 | 75 | ' Option: observable (OnPropertyChanged) enabled 76 | 77 | ' Option: pre-observable (OnPropertyChanging) enabled 78 | 79 | ' Option: partial methods (On*Changing/On*Changed) enabled 80 | 81 | ' Option: missing-value detection (*Specified/ShouldSerialize*/Reset*) enabled 82 | 83 | ' Option: light framework (CF/Silverlight) enabled 84 | 85 | ' Option: proto-rpc enabled 86 | 87 | 88 | 89 | 90 | 91 | ' Generated from: 92 | 93 | 94 | 95 | 96 | 97 | 98 | Namespace 99 | 100 | 101 | 102 | End Namespace 103 | 104 | 105 | ' Note: requires additional types generated from: 106 | 107 | 108 | 109 | 110 | <Global.System.Serializable, Global.ProtoBuf.ProtoContract(Name:="")> _ 111 | <Global.System.Runtime.Serialization.DataContract(Name:="")> _ 112 | 113 | 114 | <Global.System.Serializable, Global.ProtoBuf.ProtoContract(Name:="")> _ 115 | <Global.System.Xml.Serialization.XmlType(TypeName:="")> _ 116 | 117 | 118 | <Global.System.Serializable, Global.ProtoBuf.ProtoContract(Name:="")> _ 119 | 120 | Public Partial Class 122 | implements Global.ProtoBuf.IExtensible, Global.System.Runtime.Serialization.ISerializable, Global.System.ComponentModel.INotifyPropertyChanged, Global.System.ComponentModel.INotifyPropertyChanging 126 | 127 | Public Sub New 128 | End Sub 129 | 130 | Protected Sub New(ByVal info As Global.System.Runtime.Serialization.SerializationInfo, ByVal context As Global.System.Runtime.Serialization.StreamingContext) 131 | MyBase.New() 132 | Global.ProtoBuf.Serializer.Merge(info, Me) 133 | End Sub 134 | 135 | Sub GetObjectData(ByVal info As Global.System.Runtime.Serialization.SerializationInfo, ByVal context As Global.System.Runtime.Serialization.StreamingContext) implements Global.System.Runtime.Serialization.ISerializable.GetObjectData 136 | Global.ProtoBuf.Serializer.Serialize(info, Me) 137 | End Sub 138 | 139 | 140 | Public Event PropertyChanged As Global.System.ComponentModel.PropertyChangedEventHandler Implements Global.System.ComponentModel.INotifyPropertyChanged.PropertyChanged 141 | Protected Overridable Sub OnPropertyChanged(ByVal propertyName As String) 142 | RaiseEvent PropertyChanged(Me, New Global.System.ComponentModel.PropertyChangedEventArgs(propertyName)) 143 | End Sub 144 | 145 | Public Event PropertyChanging As Global.System.ComponentModel.PropertyChangingEventHandler Implements Global.System.ComponentModel.INotifyPropertyChanging.PropertyChanging 146 | Protected Overridable Sub OnPropertyChanging(ByVal propertyName As String) 147 | RaiseEvent PropertyChanging(Me, New Global.System.ComponentModel.PropertyChangingEventArgs(propertyName)) 148 | End Sub 149 | 150 | Private extensionObject As Global.ProtoBuf.IExtension 151 | Function GetExtensionObject(createIfMissing As Boolean) As Global.ProtoBuf.IExtension Implements Global.ProtoBuf.IExtensible.GetExtensionObject 152 | Return Global.ProtoBuf.Extensible.GetExtensionObject(extensionObject, createIfMissing) 153 | End Function 154 | End Class 155 | 156 | 157 | 158 | 159 | 160 | 161 | 165 | 166 | 167 | 168 | 169 | Public Enum 170 | 171 | End Enum 172 | 173 | 174 | 175 | 176 | 177 | 178 | = 179 | 180 | 0 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | FixedSize 198 | Group 199 | TwosComplement 202 | ZigZag 203 | Default 204 | 205 | 206 | 207 | 208 | struct 209 | struct 210 | struct 211 | struct 212 | struct 213 | struct 214 | struct 215 | struct 216 | struct 217 | class 218 | class 219 | struct 220 | struct 221 | struct 222 | struct 223 | struct 224 | struct 225 | none 226 | 227 | 228 | Field type not implemented: (.) 229 | 230 | 231 | 232 | 233 | 234 | 235 | double 236 | Double 237 | Single 238 | Long 239 | ULong 240 | Integer 241 | ULong 242 | UInteger 243 | Boolean 244 | String 245 | Byte() 246 | UInteger 247 | Integer 248 | Long 249 | Integer 250 | Long 251 | 252 | 253 | 254 | 255 | 256 | Field type not implemented: (.) 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | "" 266 | . 267 | ' 268 | CType(, ) 269 | 270 | 271 | 272 | 280 | 281 | 282 | 283 | 284 | . 285 | . 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 0.0 295 | 0.0F 296 | 0L 297 | 0L 298 | 0 299 | 0L 300 | 0 301 | False 302 | "" 303 | Nothing 304 | 0 305 | 0 306 | 0L 307 | 0 308 | 0L 309 | Nothing 310 | . 311 | Nothing 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | Nullable(Of ) 323 | 324 | 325 | 326 | Private = 327 | 328 | 329 | Private = 330 | 331 | 332 | 333 | 334 | <Global.ProtoBuf.ProtoMember(, IsRequired:=False, Name:="", DataFormat:=Global.ProtoBuf.DataFormat.)> _ 335 | 336 | 337 | <Global.System.ComponentModel.DefaultValue(CType(, ))> _ 338 | 339 | 340 | <Global.System.ComponentModel.DefaultValue(CType(, ))> _ 341 | 342 | 343 | <Global.System.Xml.Serialization.XmlElement("", Order:=)> _ 345 | 346 | <Global.ProtoBuf.ProtoMember(, IsRequired:=False, Name:="", DataFormat:=Global.ProtoBuf.DataFormat.)> _ 347 | 348 | 349 | <Global.System.ComponentModel.DefaultValue(CType(, ))> _ 350 | 351 | 352 | <Global.System.ComponentModel.DefaultValue(CType(, ))> _ 353 | 354 | 355 | <Global.System.Runtime.Serialization.DataMember(Name:="", Order:=, IsRequired:=False)> _ 357 | 358 | <Global.ProtoBuf.ProtoMember(, IsRequired:=False, Name:="", DataFormat:=Global.ProtoBuf.DataFormat.)> _ 360 | 361 | <Global.System.ComponentModel.DefaultValue(CType(, ))> _ 363 | 364 | <Global.System.ComponentModel.DefaultValue(CType(, ))> _ 366 | 368 | 369 | <Global.ProtoBuf.ProtoMember(, IsRequired:=False, Name:="", DataFormat:=Global.ProtoBuf.DataFormat.)> _ 370 | <Global.System.Runtime.Serialization.DataMember(Name:="", Order:=, IsRequired:=False)> _ 372 | 373 | <Global.ProtoBuf.ProtoMember(, IsRequired:=False, Name:="", DataFormat:=Global.ProtoBuf.DataFormat.)> _ 374 | <Global.System.Xml.Serialization.XmlElement("", Order:=)> _ 376 | 377 | <Global.ProtoBuf.ProtoMember(, IsRequired:=False, Name:="", DataFormat:=Global.ProtoBuf.DataFormat.)> _ 379 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | Private 411 | 412 | 413 | <Global.ProtoBuf.ProtoMember(, IsRequired:=True, Name:="", DataFormat:=Global.ProtoBuf.DataFormat.)> _ 414 | <Global.System.Runtime.Serialization.DataMember(Name:="", Order:=, IsRequired:=True)> _ 416 | 417 | <Global.ProtoBuf.ProtoMember(, IsRequired:=True, Name:="", DataFormat:=Global.ProtoBuf.DataFormat.)> _ 418 | <Global.System.Xml.Serialization.XmlElement("", Order:=)> _ 420 | 421 | <Global.ProtoBuf.ProtoMember(, IsRequired:=True, Name:="", DataFormat:=Global.ProtoBuf.DataFormat.)> _ 423 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | Public Property 443 | 444 | 445 | Public Property 446 | 447 | 448 | Get 449 | 450 | Return 453 | 454 | If Not Is Nothing Then 455 | Return 456 | Else 457 | Return 458 | End If 460 | Return 463 | 464 | End Get 465 | 466 | 467 | Set() 468 | 469 | 470 | Set() 471 | 472 | 473 | OnChanging(value) 474 | OnPropertyChanging("") 475 | = value 476 | OnPropertyChanged("") OnChanged() 477 | End Set 478 | End Property 479 | 480 | partial void OnChanging( value); 481 | partial void OnChanged(); 482 | <Global.System.Xml.Serialization.XmlIgnore> _ 483 | <Global.System.ComponentModel.Browsable(false)> _ 484 | 485 | 486 | Public Property Specified As Boolean 487 | Get 488 | Return .HasValue 489 | End Get 490 | Set (ByVal value As Boolean) 491 | If Not .HasValue Then 492 | If value = True then = 493 | Else 494 | If value = False then = Nothing 495 | End If 496 | End Set 497 | End Property 498 | 499 | 500 | Public Property Specified As Boolean 501 | Get 502 | Return IsNot Nothing 503 | End Get 504 | Set (ByVal value As Boolean) 505 | If Is Nothing Then 506 | If value = True then = 507 | Else 508 | If value = False then = Nothing 509 | End If 510 | End Set 511 | End Property 512 | 513 | 514 | Private Function ShouldSerialize() As Boolean 515 | Return Specified 516 | End Function 517 | Private Sub Reset() 518 | Specified = false 519 | End Sub 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | Private ReadOnly as Global.System.Collections.Generic.List(Of ) = New Global.System.Collections.Generic.List(Of )() 529 | 530 | 531 | Private ReadOnly as Global.System.Collections.Generic.List(Of ) = New Global.System.Collections.Generic.List(Of )() 532 | 533 | 534 | 535 | 536 | <Global.ProtoBuf.ProtoMember(, Name:="", DataFormat:=Global.ProtoBuf.DataFormat.)> _ 537 | <Global.System.Runtime.Serialization.DataMember(Name:="", Order:=, IsRequired:=False)> _ 538 | 539 | 540 | <Global.ProtoBuf.ProtoMember(, Name:="", DataFormat:=Global.ProtoBuf.DataFormat.)> _ 541 | <Global.System.Xml.Serialization.XmlElement("", Order:=)> _ 542 | 543 | 544 | <Global.ProtoBuf.ProtoMember(, Name:="", DataFormat:=Global.ProtoBuf.DataFormat.)> _ 545 | 546 | 548 | Public ReadOnly Property As Global.System.Collections.Generic.List(Of ) 550 | 551 | Public ReadOnly Property As Global.System.Collections.Generic.List(Of ) 553 | 554 | 555 | Get 556 | Return 557 | End Get 558 | 559 | 560 | 561 | Set (value As Global.System.Collections.Generic.List(Of )) 562 | 563 | 564 | Set (value As Global.System.Collections.Generic.List(Of )) 565 | 566 | 567 | = value 568 | End Set 569 | 570 | End Property 571 | 572 | 573 | 574 | 575 | <Global.System.ServiceModel.ServiceContract(Name:="")> _ 576 | 577 | Public Interface I 578 | 579 | End Interface 580 | 581 | 582 | Public Class Client : Global.ProtoBuf.ServiceModel.RpcClient 583 | public Client() : base(typeof(I)) { } 584 | 585 | 586 | End Class 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | <Global.System.ServiceModel.OperationContract(Name:="")> _ 595 | <Global.ProtoBuf.ServiceModel.ProtoBehavior()> _ 596 | 597 | ( request); 598 | 599 | <Global.System.ServiceModel.OperationContract(AsyncPattern:=True, Name:="")> _ 600 | Global.System.IAsyncResult Begin( request, Global.System.AsyncCallback callback, object state); 601 | End(Global.System.IAsyncResult ar); 602 | 603 | 604 | 605 | 606 | ( request) 607 | { 608 | return () Send("", request); 609 | } 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | Public Class CompletedEventArgs : Global.System.ComponentModel.AsyncCompletedEventArgs 619 | private object[] results; 620 | 621 | public CompletedEventArgs(object[] results, Global.System.Exception exception, bool cancelled, object userState) 622 | : base(exception, cancelled, userState) 623 | { 624 | this.results = results; 625 | } 626 | 627 | public Result 628 | { 629 | get { 630 | base.RaiseExceptionIfNecessary(); 631 | return ()(this.results[0]); 632 | } 633 | } 634 | End Class 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ 643 | public partial class Client : Global.System.ServiceModel.ClientBase<I>, I 644 | { 645 | 646 | public Client() 647 | {} 648 | public Client(string endpointConfigurationName) 649 | : base(endpointConfigurationName) 650 | {} 651 | public Client(string endpointConfigurationName, string remoteAddress) 652 | : base(endpointConfigurationName, remoteAddress) 653 | {} 654 | public Client(string endpointConfigurationName, Global.System.ServiceModel.EndpointAddress remoteAddress) 655 | : base(endpointConfigurationName, remoteAddress) 656 | {} 657 | public Client(Global.System.ServiceModel.Channels.Binding binding, Global.System.ServiceModel.EndpointAddress remoteAddress) 658 | : base(binding, remoteAddress) 659 | {} 660 | 661 | 662 | } 663 | 664 | 665 | 666 | 667 | 668 | private BeginOperationDelegate onBeginDelegate; 669 | private EndOperationDelegate onEndDelegate; 670 | private Global.System.Threading.SendOrPostCallback onCompletedDelegate; 671 | 672 | public event Global.System.EventHandler<CompletedEventArgs> Completed; 673 | 674 | public ( request) 675 | { 676 | return base.Channel.(request); 677 | } 678 | 679 | <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ 680 | public Global.System.IAsyncResult Begin( request, Global.System.AsyncCallback callback, object asyncState) 681 | { 682 | return base.Channel.Begin(request, callback, asyncState); 683 | } 684 | 685 | <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ 686 | public End(Global.System.IAsyncResult result) 687 | { 688 | return base.Channel.End(result); 689 | } 690 | 691 | private Global.System.IAsyncResult OnBegin(object[] inValues, Global.System.AsyncCallback callback, object asyncState) 692 | { 693 | request = (()(inValues[0])); 694 | return this.Begin(request, callback, asyncState); 695 | } 696 | 697 | private object[] OnEnd(Global.System.IAsyncResult result) 698 | { 699 | retVal = this.End(result); 700 | return new object[] { 701 | retVal}; 702 | } 703 | 704 | private void OnCompleted(object state) 705 | { 706 | if ((this.Completed != null)) 707 | { 708 | InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state)); 709 | this.Completed(this, new CompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState)); 710 | } 711 | } 712 | 713 | public void Async( request) 714 | { 715 | this.Async(request, null); 716 | } 717 | 718 | public void Async( request, object userState) 719 | { 720 | if ((this.onBeginDelegate == null)) 721 | { 722 | this.onBeginDelegate = new BeginOperationDelegate(this.OnBegin); 723 | } 724 | if ((this.onEndDelegate == null)) 725 | { 726 | this.onEndDelegate = new EndOperationDelegate(this.OnEnd); 727 | } 728 | if ((this.onCompletedDelegate == null)) 729 | { 730 | this.onCompletedDelegate = new Global.System.Threading.SendOrPostCallback(this.OnCompleted); 731 | } 732 | base.InvokeAsync(this.onBeginDelegate, new object[] { 733 | request}, this.onEndDelegate, this.onCompletedDelegate, userState); 734 | } 735 | 736 | 737 | 738 | 739 | [] 740 | 741 | 742 | |AddHandler|AddressOf|Alias|And|AndAlso|As|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|CBool|CByte|CChar|CDate|CDec|CDbl|Char|CInt|Class|CLng|CObj|Const|Continue|CSByte|CShort|CSng|CStr|CType|CUInt|CULng|CUShort|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else|ElseIf|End|EndIf|Enum|Erase|Error|Event|Exit|False|Finally|For|Friend|Function|Get|GetType|GetXMLNamespace|Global|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|IsNot|Let|Lib|Like|Long|Loop|Me|Mod|Module|MustInherit|MustOverride|MyBase|MyClass|Namespace|Narrowing|New|Next|Not|Nothing|NotInheritable|NotOverridable|Object|Of|On|Operator|Option|Optional|Or|OrElse|Overloads|Overridable|Overrides|ParamArray|Partial|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|REM|RemoveHandler|Resume|Return|SByte|Select|Set|Shadows|Shared|Short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|True|Try|TryCast|TypeOf|Variant|Wend|UInteger|ULong|UShort|Using|When|While|Widening|With|WithEvents|WriteOnly|Xor| 743 | 744 | 745 | 746 | --------------------------------------------------------------------------------