1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SCRtcFactory
- {
- private static SCRtcFactory _instance;
- public static SCRtcFactory Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new SCRtcFactory();
- }
- return _instance;
- }
- }
- public SCRtcManager mSCRtcManager;
- public SCRtcHandle mSCRtcHandle;
- public SCRtcMe mSCRtcMe;
- public SCRtcPeers mSCRtcPeers;
- public bool isClose = true;
- public SCRtcFactory()
- {
- mSCRtcHandle = SCRtcHandle.Instance;
- }
- public SCRtcConfig mSCRtcConfig;
- public void init(SCRtcConfig sRtc, SCRtcManager ms, SCRtcMe me, SCRtcPeers sPeers=null)
- {
- this.mSCRtcConfig = sRtc;
- if (sPeers != null)
- {
- this.mSCRtcPeers = sPeers;
- }
- else
- {
- this.mSCRtcPeers = new SCRtcPeers();
- }
- this.mSCRtcManager = ms;
- if (me != null)
- {
- this.mSCRtcMe = me;
- }
- else
- {
- this.mSCRtcMe = new SCRtcMe();
- }
- mSCRtcHandle.InitRTC(sRtc);
- isClose = false;
- }
- public void Close()
- {
- this.mSCRtcHandle.Close();
- //
- }
- public void Update()
- {
- if(!isClose)
- {
- mSCRtcHandle.goThread();
- if (this.mSCRtcManager != null)
- {
- if (this.mSCRtcManager.queue.Count > 0)
- this.mSCRtcManager.OnRtcListener(this.mSCRtcManager.queue.Dequeue());
- }
- if (mSCRtcMe != null)
- mSCRtcMe.updateTexture();
- if (mSCRtcPeers != null)
- mSCRtcPeers.updateTextures();
- }
- }
- }
|