Пример #1
0
        /// <summary>
        /// Start the thread for elaborate the images and sending it
        /// </summary>
        /// <param name="callbackOnError">function to call on error</param>
        /// <param name="callbackSocketClose">function to call when socket is close</param>
        private void StartThreads(OnFrameSendingError callbackOnError, OnSocketClose callbackSocketClose)
        {
            endElaboration = false;
            requests       = new ConcurrentQueue <FrameNode>();
            Debug.Log("Parameter set");
            encodingThread = new Thread(JpegEncoding);
            encodingThread.Start();
            sendingThread = new Thread(ImageSending);
            sendingThread.Start();

            this.callbackOnFrameSendingError = callbackOnError;
            this.callbackOnClose             = callbackSocketClose;
            Debug.Log("Thread start");
        }
Пример #2
0
 /// <summary>
 /// Set the session ID of the session that client need to join
 /// </summary>
 /// <param name="position">the socket ID</param>
 /// <param name="streamId">the ID of the stream</param>
 public bool InitConnectionAsClient(string serverIpAddress, uint serverPort, string phoneId, ulong maximumRate, string streamId, OnFrameSendingError callbackOnError, OnSocketClose callbackSocketClose)
 {
     initLibrary(maximumRate);
     setSessionIdentifier(connectionId, streamId);
     return(startSocket(serverIpAddress, serverPort, phoneId, callbackOnError, callbackSocketClose));
 }
Пример #3
0
        /// <summary>
        /// Start the connection and if success the threads to elaborate and send the frames
        /// </summary>
        /// <param name="serverIpAddress">IP address</param>
        /// <param name="serverPort">Elaboration Server Port</param>
        /// <param name="phoneId">A UUID of the phone that make the connection</param>
        /// <param name="callbackOnError">function to call on error</param>
        /// <param name="callbackSocketClose">function to call when socket is close</param>
        /// <returns>true if the connection success, else false</returns>
        private bool startSocket(string serverIpAddress, uint serverPort, string phoneId, OnFrameSendingError callbackOnError, OnSocketClose callbackSocketClose)
        {
            bool result = createConnection(connectionId, serverIpAddress, serverPort, phoneId);

            if (result == false)
            {
                return(false);
            }
            active = true;
            Debug.Log("Image Sending init correctly");
            StartThreads(callbackOnError, callbackSocketClose);
            return(true);
        }
Пример #4
0
        /// <summary>
        /// Init a connection to the server
        /// </summary>
        /// <param name="serverIpAddress">IP address</param>
        /// <param name="serverPort">Elaboration Server Port</param>
        /// <param name="phoneId">A UUID of the phone that make the connection</param>
        /// <param name="maximumRate">the maximum usable bandwidth by the socket</param>
        /// <param name="numberOfClients">number of clients for the session</param>
        /// <param name="callbackOnError">function to call on error</param>
        /// <param name="callbackSocketClose">function to call when socket is close</param>
        /// <returns>the UUID of the session created</returns>
        public string InitConnectionAsHost(string serverIpAddress, uint serverPort, string phoneId, ulong maximumRate, uint numberOfClients, OnFrameSendingError callbackOnError, OnSocketClose callbackSocketClose)
        {
            initLibrary(maximumRate);

            setSessionClient(connectionId, numberOfClients);
            if (startSocket(serverIpAddress, serverPort, phoneId, callbackOnError, callbackSocketClose))
            {
                return(getStreamId(connectionId));
            }
            return("");
        }