1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SCRtcPeers
- {
- private Dictionary<string, SCRtcPeer> mSCRtcPeers = new Dictionary<string, SCRtcPeer>();
- public virtual SCRtcPeer addPeers(string pid)
- {
- if (!mSCRtcPeers.ContainsKey(pid))
- {
- SCRtcPeer sp = new SCRtcPeer();
- sp.peerId = pid;
- mSCRtcPeers.Add(pid, sp);
- return sp;
- }
- return null;
- }
- public virtual SCRtcPeer addPeers(SCRtcPeer scp)
- {
- if (!mSCRtcPeers.ContainsKey(scp.peerId))
- {
- SCRtcPeer sp = scp;
- mSCRtcPeers.Add(scp.peerId, sp);
- return sp;
- }
- return null;
- }
- public void updateTextures()
- {
- foreach (SCRtcPeer value in getPeers().Values)
- {
- value.updateTexture();
- }
- }
- public virtual void removePeers(string name)
- {
- if (mSCRtcPeers.ContainsKey(name))
- {
- mSCRtcPeers.Remove(name);
- }
- }
- public virtual Dictionary<string, SCRtcPeer> getPeers()
- {
- return mSCRtcPeers;
- }
- public virtual SCRtcPeer getPeerName(string name)
- {
- foreach(SCRtcPeer v in mSCRtcPeers.Values)
- {
- if(v.name==name)
- {
- Debug.Log("查找到===>" + name);
- return v;
- }
- }
- return null;
- }
- public virtual SCRtcPeer getPeer(string name)
- {
- if (mSCRtcPeers.ContainsKey(name))
- {
- return mSCRtcPeers[name];
- }
- return null;
- }
- public void initPeers()
- {
- mSCRtcPeers = new Dictionary<string, SCRtcPeer>();
- }
- }
|