public void LoginCLick() { var param = new Dictionary <byte, object>(); param.Add(151, nameField_login.text); param.Add(152, pwdField_login.text); peer.OpCustom(101, param, true); }
private void Login(string loginEmail, string loginPassword) { _state = GameManagerState.Sending; _photonPeer.OpCustom((byte)GameOperationCode.Login, new Dictionary <byte, object> { { (byte)GameOperatorCodeParameter.Email, loginEmail }, { (byte)GameOperatorCodeParameter.Password, loginPassword } }, true); }
private void Login(string email, string password) { _state = GameManagerState.Sending; _photonPeer.OpCustom( (byte)RuneOperationCode.Login, new Dictionary <byte, object>() { { (byte)RuneOperationCodeParameter.Password, password }, { (byte)RuneOperationCodeParameter.Email, email } }, true); }
void OnGui() { if (isConnected) { if (GUILayout.Button("Send a operation.")) { Dictionary <byte, object> dict = new Dictionary <byte, object>(); dict.Add(1, "username"); dict.Add(2, "password"); peer.OpCustom(1, dict, true); } } }
void OnGUI() { if (!connected) { if (GUI.Button(new Rect(10, 10, Screen.width - 20, Screen.height * 0.3f), "Connect")) { CreateConnnect(); } } if (connected) { inputText = GUI.TextArea(new Rect(10, 10, Screen.width - Screen.width * 0.7f - 20, Screen.height * 0.3f), inputText); if (GUI.Button(new Rect(Screen.width * 0.7f + 30, 10, Screen.width * 0.2f, Screen.height * 0.3f), "Send")) { // send to server var parameters = new Dictionary <byte, object> { { (byte)ChatMsgParameterKey.Content, inputText } }; peer.OpCustom((byte)ChatOp.Msg, parameters, true); } } GUI.TextArea(new Rect(10, Screen.height - Screen.height * 0.5f - 10, Screen.width - 20, Screen.height * 0.5f), outText); }
public void SendLoginOperation(string name) { PhotonPeer.OpCustom((byte)OperationCode.Login, new Dictionary <byte, object> { { (byte)ParameterCode.CharacterName, name } }, true); }
static void Main(string[] args) { ChatServerListener listener = new ChatServerListener(); PhotonPeer peer = new PhotonPeer(listener, ConnectionProtocol.Tcp); //连接服务器 peer.Connect("127.0.0.1:4520", "ChatServer"); Console.WriteLine("Connecting..."); while (listener.isConnected == false) { peer.Service(); } Dictionary <byte, object> dict = new Dictionary <byte, object>(); dict.Add(1, "username"); dict.Add(2, "password"); peer.OpCustom(1, dict, true); while (true) { peer.Service(); } Console.ReadKey(); }
static void Main(string[] args) { GameServerListener listener = new GameServerListener(); PhotonPeer peer = new PhotonPeer(listener, ConnectionProtocol.Tcp); Console.WriteLine("connecting..."); peer.Connect("127.0.0.1:4530", "GameServer"); while (!listener.isConnected) { peer.Service(); } Dictionary <byte, Object> dict = new Dictionary <byte, object> { { 1, "username" }, { 2, "password" } }; peer.OpCustom(1, dict, true); while (true) { peer.Service(); } }
/// <summary> /// リクエスト送信 /// </summary> /// <param name="SendPacket">送信パケット</param> /// <param name="ResponsePacketID">レスポンスパケットのID</param> /// <param name="ResponseHandler">リクエストに対応するレスポンスのハンドラ</param> public void SendRequest(IPacket SendPacket, EPacketID ResponsePacketID, Action <IDictionaryStream> ResponseHandler) { if (Peer == null) { Debug.LogError("Peer is null."); return; } byte ByteID = (byte)ResponsePacketID; ResponseHandlers.Add(ByteID, ResponseHandler); DictionaryStreamWriter Writer = new DictionaryStreamWriter(); SendPacket.Serialize(Writer); Peer.OpCustom((byte)SendPacket.PacketID, Writer.Dest, false); }
private void ExecuteCommand(string cmd) { if (!connected) { return; } switch (cmd.Trim().ToLower()) { case "push": { Dictionary <byte, object> parameters = new Dictionary <byte, object> { { (byte)ParameterCode.Type, (byte)ClientSettings.Default.PushType }, { (byte)ParameterCode.Body, ClientSettings.Default.Body }, { (byte)ParameterCode.Title, ClientSettings.Default.Title } }; mPeer.OpCustom((byte)SelectCharacterOperationCode.SendPushToPlayers, parameters, true); Console.WriteLine("push sended"); } break; case "exit": { mPeer.Disconnect(); mLoopStarted = false; } break; } }
private void LoginToServer() { Console.WriteLine("\n請輸入帳號:"); string name = Console.ReadLine(); Console.WriteLine("\n請輸入密碼:"); string password = Console.ReadLine(); var parameters = new Dictionary <byte, object> { { (byte)LoginParameterCode.Name, name }, { (byte)LoginParameterCode.Password, password }, }; m_Peer.OpCustom((byte)OperationCode.Login, parameters, true); }
public void SendChatMessage(string message) { PhotonPeer.OpCustom((byte)OperationCode.SendChatMessage, new Dictionary <byte, object> { { (byte)ParameterCode.ChatMessage, message } }, true); }
void userLogin(string uname, string pwd) { Dictionary <byte, object> param = new Dictionary <byte, object>(); param.Add((byte)ScOpEnumCommon.OpKeyEnum.UserName, uname); param.Add((byte)ScOpEnumCommon.OpKeyEnum.PassWord, pwd); peer.OpCustom((byte)ScOpEnumCommon.OpCodeEnum.Login, param, true); }
/// <summary> /// Forwards the request to the peer which then sends the request to the server. /// </summary> internal static void ForwardRequest(OperationRequest operationRequest, bool sendReliable, byte channelId) { if (m_PhotonPeer == null) { Debug.LogError("Not connected"); return; } m_PhotonPeer.OpCustom(operationRequest, sendReliable, channelId, m_Encrypt); }
/// <summary> /// Creates a new character /// </summary> public static void CreateCharacter(PhotonPeer peer, CharacterStructure characterInfo) { var parameters = new Dictionary <byte, object>() { { (byte)1, (byte)GameOperationCode.CreateCharacter }, { (byte)ParameterCode.Data, characterInfo }, }; peer.OpCustom((byte)ClientOperationCode.Character, parameters, true); }
private void SendServer(string message) { _photonPeer.OpCustom( 1, new Dictionary <byte, object> { { 0, message } }, true); }
public void MoveOperation(float x, float y, float z) { PhotonPeer.OpCustom((byte)OperationCode.Move, new Dictionary <byte, object> { { (byte)ParameterCode.PosX, x }, { (byte)ParameterCode.PosY, y }, { (byte)ParameterCode.PosZ, z }, }, false); }
public void SendOperation(IANTProtocol.OperationCode oprationCode, Dictionary <byte, object> parameter) { if (peer.IsEncryptionAvailable) { peer.OpCustom((byte)oprationCode, parameter, true, 0, true); } else { DebugReturn(DebugLevel.ERROR, "communication still not establish encryption"); } }
/// <summary> /// 向服务器发请求 /// </summary> /// <param name="OpCode">操作码</param> /// <param name="SubCode">子操作码</param> /// <param name="parameters">参数</param> public void Request(byte OpCode, byte SubCode, params object[] parameters) { Dictionary <byte, object> dict = new Dictionary <byte, object>(); dict[80] = SubCode; for (byte i = 0; i < parameters.Length; i++) { dict[(byte)i] = parameters[i]; } bool ispeer = peer.OpCustom(OpCode, dict, true); }
/// <summary> /// Logs in a user /// </summary> public static void Login(PhotonPeer peer, string username, string password) { var parameters = new Dictionary <byte, object>() { { (byte)1, (byte)GameOperationCode.LoginUser }, { (byte)ParameterCode.Username, username }, { (byte)ParameterCode.Password, password }, }; peer.OpCustom((byte)ClientOperationCode.Login, parameters, true, 0, true); }
void OnGUI() { GUILayout.Label("Connected: " + connected.ToString()); if (connected) { if (GUILayout.Button("Send Operation Request")) { // send a message to the server peer.OpCustom(0, new Dictionary <byte, object>(), true); } } }
/// <summary> /// 向服务器发请求 /// </summary> /// <param name="OpCode">操作码</param> /// <param name="SubCode">子操作码</param> /// <param name="parameters">传递参数</param> public void Request(byte OpCode, byte SubCode, params object[] parameters) { //创建参数字典 Dictionary <byte, object> dict = new Dictionary <byte, object>(); //指定子操作码 dict[80] = SubCode; for (int i = 0; i < parameters.Length; i++) { dict[(byte)i] = parameters[i]; } peer.OpCustom(OpCode, dict, true); }
private void OnGUI() { if (GUILayout.Button("send")) { if (this.Status) { peer.OpCustom(1, new Dictionary <byte, object>() { { 10, " hello world " } }, true); } } }
public void SendEvent(Message req) { string json = JsonMapper.ToJson(req); Dictionary <byte, object> datas = new Dictionary <byte, object>(); datas.Add(1, req.Code); datas.Add(2, json); if (peer == null) { GUIManager.Instance.OpenTipsView("链接服务器失败", "确定", () => { }); } else { peer.OpCustom(1, datas, true); } }
void INetChannel.Send(Message msg) { MemoryStream stream = new MemoryStream(); BinaryWriter writer = new BinaryWriter(stream); msg.Serialize(writer); var arr = new byte[stream.Position]; Array.Copy(stream.GetBuffer(), arr, stream.Position); var data = new Dictionary <byte, object>(); data[0] = arr; bool isReliable = msg.Reliability == MessageReliability.Reliable || msg.Reliability == MessageReliability.ReliableOrdered; _photon.OpCustom(42, data, isReliable); //Photon does not allow to send raw messages so send dummy operation instead }
protected void SendToServer(INetworkMessage message, bool reliable, byte channel) { var baseMessage = message as NetworkMessageBase; if (baseMessage != null) { baseMessage.PlayerName = playerName; } if (selfPeer != null) { var messageData = serializer.ToMessageData(message); if (messageData.Value != null) { selfPeer.OpCustom(messageData.Key, messageData.Value, reliable, channel); } } }
//private static /// <summary> /// Creates the client. /// </summary> /// <param name="localhost">Localhost.</param> /// <param name="seerverName">Seerver name.</param> public static void CreateClient(string localhost, string seerverName) { if (instance != null) { Debug.Log("客户端已经创建"); return; } localhost = "127.0.0.1:4530"; seerverName = "ChatServer"; //参数检查 GameClient listener = new GameClient(); listener.clientState = ClientState.DisConnect; photonPeer = new PhotonPeer(listener, ConnectionProtocol.Tcp); photonPeer.Connect(localhost, seerverName); //链接服务器 Debug.Log("连接服务器中......"); //启动异步客户端服务 while (listener.clientState == ClientState.DisConnect) { photonPeer.Service(); } Dictionary <byte, object> dict = new Dictionary <byte, object>(); dict.Add(1, "username"); dict.Add(2, "password"); //向服务端发送请求 photonPeer.OpCustom(1, dict, true); while (true) { photonPeer.Service(); } }
private static void toTestPhoton() { PeerListener listener = new PeerListener(); var peer = new PhotonPeer(listener, ConnectionProtocol.Tcp); peer.Connect("127.0.0.1:4530", "ChatServer"); while (!listener.Status) { peer.Service(); } peer.OpCustom(1, new Dictionary <byte, object>() { { 10, " hello world " } }, true); while (true) { peer.Service(); } Console.WriteLine("end"); }
public static void Main() { var client = new ChatClient(); var peer = new PhotonPeer(client, ConnectionProtocol.Tcp); // connect client.connected = false; peer.Connect("127.0.0.1:4530", "ChatServer"); while (!client.connected) { peer.Service(); } var buffer = new StringBuilder(); while (true) { peer.Service(); // read input if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); if (key.Key != ConsoleKey.Enter) { // store input buffer.Append(key.KeyChar); } else { // send to server var parameters = new Dictionary<byte, object> { { 1, buffer.ToString() } }; peer.OpCustom(1, parameters, true); buffer.Length = 0; } } } }
public void Request(byte OpCode, byte SubCode, params object[] parameters) { OperationRequest request = new OperationRequest(); request.OperationCode = OpCode; request.Parameters = new Dictionary <byte, object>(); request.Parameters[80] = SubCode; for (int i = 0; i < parameters.Length; i++) { request.Parameters[(byte)i] = parameters[i]; } peer.OpCustom(OpCode, request.Parameters, true); ////创建参数字典 //Dictionary<byte, object> OpParameters = new Dictionary<byte, object>(); ////指定子操作码 //OpParameters[80] = SubCode; ////赋值参数 //for (int i = 0; i < parameters.Length; i++) //{ // OpParameters[(byte)i] = parameters[i]; //} ////发送 //peer.OpCustom(OpCode, OpParameters, true); }
public void SendRequest(OperationCode opCode, Dictionary <byte, object> parameters) { Debug.Log("sendrequest to server , opcode : " + opCode); peer.OpCustom((byte)opCode, parameters, true); }