SCRtcPeers.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class SCRtcPeers
  5. {
  6. private Dictionary<string, SCRtcPeer> mSCRtcPeers = new Dictionary<string, SCRtcPeer>();
  7. public virtual SCRtcPeer addPeers(string pid)
  8. {
  9. if (!mSCRtcPeers.ContainsKey(pid))
  10. {
  11. SCRtcPeer sp = new SCRtcPeer();
  12. sp.peerId = pid;
  13. mSCRtcPeers.Add(pid, sp);
  14. return sp;
  15. }
  16. return null;
  17. }
  18. public virtual SCRtcPeer addPeers(SCRtcPeer scp)
  19. {
  20. if (!mSCRtcPeers.ContainsKey(scp.peerId))
  21. {
  22. SCRtcPeer sp = scp;
  23. mSCRtcPeers.Add(scp.peerId, sp);
  24. return sp;
  25. }
  26. return null;
  27. }
  28. public void updateTextures()
  29. {
  30. foreach (SCRtcPeer value in getPeers().Values)
  31. {
  32. value.updateTexture();
  33. }
  34. }
  35. public virtual void removePeers(string name)
  36. {
  37. if (mSCRtcPeers.ContainsKey(name))
  38. {
  39. mSCRtcPeers.Remove(name);
  40. }
  41. }
  42. public virtual Dictionary<string, SCRtcPeer> getPeers()
  43. {
  44. return mSCRtcPeers;
  45. }
  46. public virtual SCRtcPeer getPeer(string name)
  47. {
  48. if (mSCRtcPeers.ContainsKey(name))
  49. {
  50. return mSCRtcPeers[name];
  51. }
  52. return null;
  53. }
  54. public void initPeers()
  55. {
  56. mSCRtcPeers = new Dictionary<string, SCRtcPeer>();
  57. }
  58. }