public Texture2D getTexture() { state = VNCPluginInterface.getEnumConnectionState(); switch (state) { case VNCPluginInterface.ConnectionState.Connected: needNewtexture = false; break; case VNCPluginInterface.ConnectionState.BufferSizeChanged: needNewtexture = true; TextureSize = new Size( VNCPluginInterface.getDesktopWidth(), VNCPluginInterface.getDesktopHeight()); break; case VNCPluginInterface.ConnectionState.Error: if (ConnectionLost != null) { ConnectionLost(this, new ErrorEventArg("Error From plugin")); } break; default: Debug.LogWarning("Stange behaviour"); break; } if (needNewtexture) { needNewtexture = false; texture = pluginInterface.CreateTextureAndPassToPlugin(BufferSize); } return(texture); }
private IEnumerator Connection() { VNCPluginInterface.Connect(connectionInfos.host, connectionInfos.port, connectionInfos.display, connectionInfos.viewOnly); while (true) { bool exit = false; try { state = VNCPluginInterface.getEnumConnectionState(); switch (state) { case VNCPluginInterface.ConnectionState.Iddle: break; case VNCPluginInterface.ConnectionState.Connecting: break; case VNCPluginInterface.ConnectionState.PasswordNeeded: onConnection(null, true); break; case VNCPluginInterface.ConnectionState.Connected: onConnection(null, false); exit = true; break; case VNCPluginInterface.ConnectionState.BufferSizeChanged: onConnection(null, false); needNewtexture = true; TextureSize = new Size( VNCPluginInterface.getDesktopWidth(), VNCPluginInterface.getDesktopHeight()); break; case VNCPluginInterface.ConnectionState.Error: if (ConnectionLost != null) { ConnectionLost(this, new ErrorEventArg("Error From plugin")); } Debug.LogError("Connection Error"); exit = true; break; } } catch (Exception e) { if (!(e is ThreadAbortException)) { onConnection(e, false); } } if (exit) { break; } yield return(new WaitForSeconds(0.25f)); } }