// Initializes the network transport and builds the _channel array. // Returns null on failure, and sets error string with description. protected ConnectionConfig InitializeNetwork( out string error ) { _maxEventCount = _commonSettings.maxEventCount > 0 ? _commonSettings.maxEventCount : UInt32.MaxValue; GlobalConfig gConfig = new GlobalConfig(); // default settings gConfig.MaxPacketSize = _commonSettings.messageBufferSize; NetworkTransport.Init(); ConnectionConfig config = new ConnectionConfig(); config.SendDelay = 0; int channelCount = AlpacaConstant.InternalChannelCount + _commonSettings.customChannel.Length; _channel = new Channel[channelCount]; // add internal channels for( int i = 0; i < AlpacaConstant.InternalChannelCount; ++i ) { string name = AlpacaConstant.INTERNAL_CHANNEL_NAME[i]; QosType qos = AlpacaConstant.INTERNAL_CHANNEL_TYPE[i]; int index = config.AddChannel( qos ); if( index != i ) { error = Log.PrefixMessage( string.Format( "Unexpected channel index {0} while attempting to create {1}", index, name ) ); return null; } _channel[i] = new Channel( ChannelIndex.CreateInternal( (InternalChannel)i ), name, qos ); } // add custom channels for( int i = 0; i < _commonSettings.customChannel.Length; ++i ) { CustomChannelSettings c = _commonSettings.customChannel[i]; int index = config.AddChannel( c.type ); int offsetIndex = i + AlpacaConstant.InternalChannelCount; if( index != offsetIndex ) { error = Log.PrefixMessage( string.Format( "Unexpected channel index {0} while attempting to create {1}", index, c.name ) ); return null; } _channel[offsetIndex] = new Channel( ChannelIndex.CreateCustom( (UInt32)i ), c.name, c.type ); } error = ""; return config; }
// sends a custom message to the server public bool SendCustomServer( uint customChannel, BitWriter writer, bool sendImmediately, out string error ) { return Send( InternalMessage.CustomServer, ChannelIndex.CreateCustom( customChannel ), writer, sendImmediately, out error ); }
// sends a custom message to the server public bool SendCustomClient( NodeIndex client, uint customChannel, BitWriter writer, bool sendImmediately, out string error ) { return Send( client, InternalMessage.CustomClient, ChannelIndex.CreateCustom( customChannel ), writer, sendImmediately, out error ); }