IpcRemoteObject.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Runtime.Remoting;
  5. using System.Runtime.Remoting.Channels;
  6. using System.Runtime.Serialization.Formatters;
  7. namespace GameEditorUnity3D
  8. {
  9. public class IpcRemoteObject : MarshalByRefObject
  10. {
  11. public delegate string RemoteCallBack(string s);
  12. public RemoteCallBack ServerCallback;
  13. private List<string> ClientMsgs = new List<string>();
  14. public string SendToServer(string s)
  15. {
  16. if (ServerCallback != null)
  17. return ServerCallback(s);
  18. else
  19. return null;
  20. }
  21. public void SendToClient(string s)
  22. {
  23. ClientMsgs.Add(s);
  24. }
  25. public List<string> RecvClientMsgs()
  26. {
  27. List<string> msg = new List<string>(ClientMsgs);
  28. ClientMsgs.Clear();
  29. return msg;
  30. }
  31. public override object InitializeLifetimeService()
  32. {
  33. return null;
  34. }
  35. }
  36. }