using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Google.Protobuf; using UnityEngine; class Battle { private JoinInfo joinInfo; private Net.ClientNet conn; public Battle(JoinInfo joinInfo) { var rootObj = new GameObject(); rootObj.AddComponent(typeof(Net.ClientNet)); this.conn = rootObj.GetComponent(); this.conn.Init("ws://192.168.100.21:7601/websocket?server_id=2"); this.conn.OnOpen += (Net.ClientNet conn) => { var joinMsg = new battle.cs.CMJoin(); joinMsg.AccountId = joinInfo.account_id; joinMsg.SessionId = joinInfo.session_id; joinMsg.TeamUuid = joinInfo.team_uuid; joinMsg.PayloadData = joinInfo.payload_data; this.conn.SendMsg(joinMsg); }; this.conn.Open(); } }