static MyFileTextureEnum GetTextureType(MyChannel channel) { MyFileTextureEnum type = MyFileTextureEnum.UNSPECIFIED; switch (channel) { case MyChannel.ColorMetal: type = MyFileTextureEnum.COLOR_METAL; break; case MyChannel.NormalGloss: type = MyFileTextureEnum.NORMALMAP_GLOSS; break; case MyChannel.Extension: type = MyFileTextureEnum.EXTENSIONS; break; case MyChannel.Alphamask: type = MyFileTextureEnum.ALPHAMASK; break; default: MyRenderProxy.Assert(false, "Channel is not recognised"); break; } return(type); }
IDynamicFileArrayTexture GetArrayTextureFromFilepath(string filepath, MyChannel channel, Vector2I defaultResolution) { MyFileTextureParams textureParams; MyArrayTextureKey key; key.Channel = channel; bool isLoaded = MyFileTextureParamsManager.LoadFromFile(filepath, out textureParams); if (isLoaded) { Format format; format = textureParams.Format; if (MyCompilationSymbols.ReinterpretFormatsStoredInFiles) { if (channel != MyChannel.NormalGloss) { format = MyResourceUtils.MakeSrgb(format); } } key.Format = format; key.ResolutionInFile = textureParams.Resolution; key.MipmapsCount = textureParams.Mipmaps; } else { Format format; switch (channel) { case MyChannel.ColorMetal: format = Format.BC7_UNorm_SRgb; break; case MyChannel.NormalGloss: format = Format.BC7_UNorm; break; case MyChannel.Extension: format = Format.BC7_UNorm_SRgb; break; case MyChannel.Alphamask: format = Format.BC4_UNorm; break; default: MyRenderProxy.Assert(false); format = Format.Unknown; break; } key.Format = format; key.ResolutionInFile = defaultResolution; key.MipmapsCount = MyResourceUtils.GetMipmapsCount(Math.Max(key.ResolutionInFile.X, key.ResolutionInFile.Y)); } return(GetArrayTextureFromKey(key)); }
int GetArrayIndexFromFilepath(string filepath, MyChannel channel, Vector2I resolution) { IDynamicFileArrayTexture fileArrayTex = GetArrayTextureFromFilepath(filepath, channel, resolution); if (fileArrayTex == null) { return(DEFAULT_ARRAY_TEXTURE_INDEX); } int index = fileArrayTex.GetOrAddSlice(filepath); return(index); }
public virtual void disconnect() { if (channel != null) { if (logPool.IsDebugEnabled) { logPool.Debug("WS disconnect [" + channel + "]"); } channel.close(); channel = null; } }
void DeviceDisconnected() { _applicationStarted = false; _hasJoined = false; _channel.Dispose(); _channel = null; _deviceManager.Dispose(); _deviceManager = null; _selectedDevice.Dispose(); _selectedDevice = null; }
public virtual async void connect(string address, SessionRequestListener networkListener, IDictionary <string, string> extraHeaders, string cookies, Proxy proxy, long timeout) { Uri uri = LsUtils.uri(address); string host = uri.Host; int port = LsUtils.port(uri); bool secure = LsUtils.isSSL(uri); try { string host4Netty = System.Net.Dns.GetHostAddresses(host)[0].ToString(); NettyFullAddress remoteAddress = new NettyFullAddress(secure, host4Netty, port, host, proxy); ExtendedNettyFullAddress extendedRemoteAddress = new ExtendedNettyFullAddress(remoteAddress, extraHeaders, cookies); WebSocketChannelPool wsPool = (WebSocketChannelPool)wsPoolManager.get(extendedRemoteAddress); IChannel ch = await wsPool.AcquireNewOr(timeout); if (ch != null) { if (ch.Active) { this.channel = new MyChannel(ch, wsPool, networkListener); WebSocketChannelHandler chHandler = new WebSocketChannelHandler(networkListener, channel); PipelineUtils.populateWSPipeline(ch, chHandler); networkListener.onOpen(); } else { log.Error("WebSocket handshake error, "); networkListener.onBroken(); } } else { log.Error("WebSocket handshake error, channel unexpectedly null"); networkListener.onBroken(); } } catch (Exception e) { log.Error("WebSocket handshake error: " + e.Message); networkListener.onBroken(); } }
void DidConnectToCastApplication(GCKDeviceManager deviceManager, GCKApplicationMetadata applicationMetadata, string sessionId, bool launchedApplication) { Console.WriteLine("application name: {0}, sessionId: {1}, wasLaunched: {2}", applicationMetadata.ApplicationName, sessionId, launchedApplication); _channel = new MyChannel { OnDidReceiveTextMessage = DidReceiveTextMessage }; _deviceManager.AddChannel(_channel); _applicationStarted = true; UpdateButtonStates(); textName.BecomeFirstResponder(); }
void Teardown(bool selectDefaultRoute) { Console.WriteLine("Teardown"); if (_apiClient != null) { if (_applicationStarted) { _applicationStarted = false; _hasJoined = false; if (_apiClient.IsConnected || _apiClient.IsConnecting) { try { CastClass.CastApi.LeaveApplication(_apiClient); if (_channel != null) { CastClass.CastApi.RemoveMessageReceivedCallbacks( _apiClient, MyChannel.CastNamespace); _channel = null; } } catch (Exception e) { Console.WriteLine("Exception while removing channel - {0}", e); } _apiClient.Disconnect(); } } _apiClient = null; } if (selectDefaultRoute) { _mediaRouter.SelectRoute(_mediaRouter.DefaultRoute); } _selectedDevice = null; _textGuess.Text = string.Empty; UpdateEnabledStates(); }
void OnApplicationConnectionResult(CastClass.IApplicationConnectionResult result) { Console.WriteLine("ApplicationConnectionResultCallback - {0}", result.Status.StatusCode); if (result.Status.IsSuccess) { Console.WriteLine("application name: {0}, status: {1}, sessionId: {2}, wasLaunched: {3}", result.ApplicationMetadata.Name, result.ApplicationStatus, result.SessionId, result.WasLaunched); _applicationStarted = true; // Create the custom message // channel _channel = new MyChannel(_apiClient) { MessageReceived = OnMessageReceived }; try { CastClass.CastApi.SetMessageReceivedCallbacks( _apiClient, MyChannel.CastNamespace, _channel); } catch (Exception e) { Console.WriteLine("Exception while creating channel - {0}", e); } UpdateEnabledStates(); _textName.RequestFocus(); } else { Console.WriteLine("application could not launch"); Teardown(true); } }
public static byte[] GetBytePattern(MyChannel channel, Format format) { if (format == Format.Unknown) return null; switch (channel) { case MyChannel.ColorMetal: if (format == Format.BC7_UNorm_SRgb || format == Format.BC7_UNorm) return MyGeneratedTexturePatterns.ColorMetal_BC7_SRgb; else break; case MyChannel.NormalGloss: if (format == Format.BC7_UNorm) return MyGeneratedTexturePatterns.NormalGloss_BC7; else break; case MyChannel.Extension: if (format == Format.BC7_UNorm_SRgb || format == Format.BC7_UNorm) return MyGeneratedTexturePatterns.Extension_BC7_SRgb; else break; case MyChannel.Alphamask: if (format == Format.BC4_UNorm) return MyGeneratedTexturePatterns.Alphamask_BC4; else break; default: break; } // No correct pattern is found, therefore we will use generated: int texelBitSize = MyResourceUtils.GetTexelBitSize(format); const int bitsInByte = 8; // Blocks are 4x4 texels in memory const int blockTexelCount = 16; int blockBitCount = texelBitSize * blockTexelCount; return new byte[blockBitCount / bitsInByte]; }
void CheckTexture(string filepath, MyChannel channel, Format format, Vector2I texSize) { MyFileTextureParams parameters; if (m_checkedFilepaths.Contains(filepath)) { return; } m_checkedFilepaths.Add(filepath); if (MyFileTextureParamsManager.LoadFromFile(filepath, out parameters)) { if (parameters.Format != format) { MyRenderProxy.Log.WriteLineAndConsole(String.Format("{0} texture '{1}' should be {2}", channel, filepath, format)); } if (parameters.Resolution != texSize) { MyRenderProxy.Log.WriteLineAndConsole(String.Format("{0} texture '{1}' should be {2}x{3}", channel, filepath, texSize.X, texSize.Y)); } } }
static MyFileTextureEnum GetTextureType(MyChannel channel) { MyFileTextureEnum type = MyFileTextureEnum.UNSPECIFIED; switch (channel) { case MyChannel.ColorMetal: type = MyFileTextureEnum.COLOR_METAL; break; case MyChannel.NormalGloss: type = MyFileTextureEnum.NORMALMAP_GLOSS; break; case MyChannel.Extension: type = MyFileTextureEnum.EXTENSIONS; break; case MyChannel.Alphamask: type = MyFileTextureEnum.ALPHAMASK; break; default: MyRenderProxy.Assert(false, "Channel is not recognised"); break; } return type; }
public WebSocketChannelHandler(RequestListener networkListener, MyChannel ch) { this.reqListenerDecorator = new RequestListenerDecorator(networkListener, ch); this.lineAssembler = new LineAssembler(reqListenerDecorator); }
IDynamicFileArrayTexture GetArrayTextureFromFilepath(string filepath, MyChannel channel, Vector2I defaultResolution) { MyFileTextureParams textureParams; MyArrayTextureKey key; key.Channel = channel; bool isLoaded = MyFileTextureParamsManager.LoadFromFile(filepath, out textureParams); if (isLoaded) { Format format; format = textureParams.Format; if (MyCompilationSymbols.ReinterpretFormatsStoredInFiles) if (channel != MyChannel.NormalGloss) format = MyResourceUtils.MakeSrgb(format); key.Format = format; key.ResolutionInFile = textureParams.Resolution; key.MipmapsCount = textureParams.Mipmaps; } else { Format format; switch(channel) { case MyChannel.ColorMetal: format = Format.BC7_UNorm_SRgb; break; case MyChannel.NormalGloss: format = Format.BC7_UNorm; break; case MyChannel.Extension: format = Format.BC7_UNorm_SRgb; break; case MyChannel.Alphamask: format = Format.BC4_UNorm; break; default: MyRenderProxy.Assert(false); format = Format.Unknown; break; } key.Format = format; key.ResolutionInFile = defaultResolution; key.MipmapsCount = MyResourceUtils.GetMipmapsCount(Math.Max(key.ResolutionInFile.X, key.ResolutionInFile.Y)); } return GetArrayTextureFromKey(key); }
public SimpleWorker(MyChannel myChannel, ILogger <SimpleWorker> logger) { _myChannel = myChannel; _logger = logger; }
public ChannelWorker(MyChannel myChannel, ILogger <ChannelWorker> logger) { _myChannel = myChannel; _logger = logger; }
void CheckTexture(string filepath, MyChannel channel, Format format, Vector2I texSize) { MyFileTextureParams parameters; if (m_checkedFilepaths.Contains(filepath)) return; m_checkedFilepaths.Add(filepath); if (MyFileTextureParamsManager.LoadFromFile(filepath, out parameters)) { if (parameters.Format != format) MyRenderProxy.Log.WriteLineAndConsole(String.Format("{0} texture '{1}' should be {2}", channel, filepath, format)); if (parameters.Resolution != texSize) MyRenderProxy.Log.WriteLineAndConsole(String.Format("{0} texture '{1}' should be {2}x{3}", channel, filepath, texSize.X, texSize.Y)); } }
public RequestListenerDecorator(RequestListener listener, MyChannel ch) { this.listener = listener; this.ch = ch; }
public static byte[] GetBytePattern(MyChannel channel, Format format) { if (format == Format.Unknown) { return(null); } switch (channel) { case MyChannel.ColorMetal: if (format == Format.BC7_UNorm_SRgb || format == Format.BC7_UNorm) { return(MyGeneratedTexturePatterns.ColorMetal_BC7_SRgb); } else { break; } case MyChannel.NormalGloss: if (format == Format.BC7_UNorm) { return(MyGeneratedTexturePatterns.NormalGloss_BC7); } else { break; } case MyChannel.Extension: if (format == Format.BC7_UNorm_SRgb || format == Format.BC7_UNorm) { return(MyGeneratedTexturePatterns.Extension_BC7_SRgb); } else { break; } case MyChannel.Alphamask: if (format == Format.BC4_UNorm) { return(MyGeneratedTexturePatterns.Alphamask_BC4); } else { break; } default: break; } // No correct pattern is found, therefore we will use generated: int texelBitSize = MyResourceUtils.GetTexelBitSize(format); const int bitsInByte = 8; // Blocks are 4x4 texels in memory const int blockTexelCount = 16; int blockBitCount = texelBitSize * blockTexelCount; return(new byte[blockBitCount / bitsInByte]); }
int GetArrayIndexFromFilepath(string filepath, MyChannel channel, Vector2I resolution) { IDynamicFileArrayTexture fileArrayTex = GetArrayTextureFromFilepath(filepath, channel, resolution); if (fileArrayTex == null) return DEFAULT_ARRAY_TEXTURE_INDEX; int index = fileArrayTex.GetOrAddSlice(filepath); return index; }