private void onClientDataReceived(IAsyncResult asyncResult) { pipeServer.EndRead(asyncResult); if (inBuffer.Length == 0) { return; } EProtocol protocol = (EProtocol)inBuffer[0]; switch (protocol) { case EProtocol.SetAttach: EAttachPoint attachPoint = (EAttachPoint)inBuffer[1]; int x = inBuffer[2]; int y = inBuffer[3]; LogManager.Instance.Log(String.Format("Client Command: 修改挂点: {0}-{1},{2}", attachPoint.ToString(), x, y)); break; } try { if (pipeServer.IsConnected) { pipeServer.Flush(); pipeServer.BeginRead(inBuffer, 0, pipeServer.InBufferSize, onClientDataReceived, pipeServer); } } catch (Exception e) { throw e; } }
public void SetAttach(EAttachPoint attachPoint, int x, int y) { foreach (var pair in PanelEditAttach.AttachPointDic) { var attachData = EffectAttachJson[pair.Key]; Vector3 pos = new Vector3(x * SpineZipReader.defaultScale, y * SpineZipReader.defaultScale, 0); pair.Value.transform.position = pos; } }
private void onSvrDataReceived(IAsyncResult asyncResult) { // 这里用不到asyncResult pipeClient.EndRead(asyncResult); EProtocol protocol = (EProtocol)inBuffer[0]; switch (protocol) { case EProtocol.PreloadAllSpine: Debug.Log("ServerCommand: PreloadSpine"); int dirLen = inBuffer[1]; string dir = Encoding.UTF8.GetString(inBuffer, 2, dirLen); Debug.Log("Preload Dir: " + dir); ToolManager.Instance.NeedPreloadSpine = true; ToolManager.Instance.SpineDir = dir; break; case EProtocol.LoadSpine: Debug.Log("ServerCommand: LoadSpine"); int nameLen = inBuffer[1]; string name = Encoding.UTF8.GetString(inBuffer, 2, nameLen); int zipLen = inBuffer[2 + nameLen]; string zipPath = Encoding.UTF8.GetString(inBuffer, 3 + nameLen, zipLen); Debug.Log("Name: " + name); Debug.Log("Zip: " + zipPath); ToolManager.Instance.NeedLoadSpine = true; ToolManager.Instance.SpineName = name; ToolManager.Instance.SpineZipPath = zipPath; // ToolManager.Instance.LoadSpine(name, zipPath); break; case EProtocol.SetAttach: print("ServerCommand SetAttach"); EAttachPoint attachPoint = (EAttachPoint)inBuffer[1]; int x = inBuffer[2]; int y = inBuffer[3]; ToolManager.Instance.SetAttach(attachPoint, x, y); break; case EProtocol.PlayAnim: print("ServerCommand PlayAnim"); ToolManager.Instance.NeedPlayAnim = true; int animNameLen = inBuffer[1]; string animName = Encoding.UTF8.GetString(inBuffer, 2, animNameLen); ToolManager.Instance.AnimName = animName; break; } pipeClient.Flush(); pipeClient.BeginRead(inBuffer, 0, pipeClient.InBufferSize, onSvrDataReceived, pipeClient); //string info = System.Text.Encoding.UTF8.GetString(inBuffer); //int len = pipeClient.ReadByte() * 256; //len += pipeClient.ReadByte(); //inBuffer = new byte[len]; //pipeClient.Read(inBuffer, 0, len); //remoteInfo = Encoding.Unicode.GetString(inBuffer); // asyncResult.AsyncState }