public static byte ToByte(SharedObjectEventType type) { switch (type) { case SharedObjectEventType.SERVER_CONNECT: return 0x01; case SharedObjectEventType.SERVER_DISCONNECT: return 0x02; case SharedObjectEventType.SERVER_SET_ATTRIBUTE: return 0x03; case SharedObjectEventType.CLIENT_UPDATE_DATA: return 0x04; case SharedObjectEventType.CLIENT_UPDATE_ATTRIBUTE: return 0x05; case SharedObjectEventType.SERVER_SEND_MESSAGE: return 0x06; case SharedObjectEventType.CLIENT_SEND_MESSAGE: return 0x06; case SharedObjectEventType.CLIENT_STATUS: return 0x07; case SharedObjectEventType.CLIENT_CLEAR_DATA: return 0x08; case SharedObjectEventType.CLIENT_DELETE_DATA: return 0x09; case SharedObjectEventType.SERVER_DELETE_ATTRIBUTE: return 0x0A; case SharedObjectEventType.CLIENT_INITIAL_DATA: return 0x0B; default: //log.error("Unknown type " + type); return 0x00; } }
private static void DecodeSharedObject(SharedObjectMessage so, ByteBuffer stream, RtmpReader reader) { while (stream.HasRemaining) { SharedObjectEventType type = SharedObjectTypeMapping.ToType(reader.ReadByte()); string key = null; object obj2 = null; int @int = stream.GetInt(); switch (type) { case SharedObjectEventType.CLIENT_STATUS: key = reader.ReadString(); obj2 = reader.ReadString(); break; case SharedObjectEventType.CLIENT_UPDATE_DATA: key = reader.ReadString(); obj2 = reader.ReadData(); break; default: if ((type != SharedObjectEventType.SERVER_SEND_MESSAGE) && (type != SharedObjectEventType.CLIENT_SEND_MESSAGE)) { if (@int > 0) { key = reader.ReadString(); if (@int > (key.Length + 2)) { obj2 = reader.ReadData(); } } } else { int position = (int)stream.Position; key = reader.ReadData() as string; List <object> list = new List <object>(); while ((stream.Position - position) < @int) { object item = reader.ReadData(); list.Add(item); } obj2 = list; } break; } so.AddEvent(type, key, obj2); } }
static SharedObjectTypeMapping() { SharedObjectEventType[] typeArray = new SharedObjectEventType[12]; typeArray[1] = SharedObjectEventType.SERVER_CONNECT; typeArray[2] = SharedObjectEventType.SERVER_DISCONNECT; typeArray[3] = SharedObjectEventType.SERVER_SET_ATTRIBUTE; typeArray[4] = SharedObjectEventType.CLIENT_UPDATE_DATA; typeArray[5] = SharedObjectEventType.CLIENT_UPDATE_ATTRIBUTE; typeArray[6] = SharedObjectEventType.SERVER_SEND_MESSAGE; typeArray[7] = SharedObjectEventType.CLIENT_STATUS; typeArray[8] = SharedObjectEventType.CLIENT_CLEAR_DATA; typeArray[9] = SharedObjectEventType.CLIENT_DELETE_DATA; typeArray[10] = SharedObjectEventType.SERVER_DELETE_ATTRIBUTE; typeArray[11] = SharedObjectEventType.CLIENT_INITIAL_DATA; _typeMap = typeArray; }
public static byte ToByte(SharedObjectEventType type) { switch (type) { case SharedObjectEventType.SERVER_CONNECT: return(0x01); case SharedObjectEventType.SERVER_DISCONNECT: return(0x02); case SharedObjectEventType.SERVER_SET_ATTRIBUTE: return(0x03); case SharedObjectEventType.CLIENT_UPDATE_DATA: return(0x04); case SharedObjectEventType.CLIENT_UPDATE_ATTRIBUTE: return(0x05); case SharedObjectEventType.SERVER_SEND_MESSAGE: return(0x06); case SharedObjectEventType.CLIENT_SEND_MESSAGE: return(0x06); case SharedObjectEventType.CLIENT_STATUS: return(0x07); case SharedObjectEventType.CLIENT_CLEAR_DATA: return(0x08); case SharedObjectEventType.CLIENT_DELETE_DATA: return(0x09); case SharedObjectEventType.SERVER_DELETE_ATTRIBUTE: return(0x0A); case SharedObjectEventType.CLIENT_INITIAL_DATA: return(0x0B); default: //log.error("Unknown type " + type); return(0x00); } }
public static string ToString(SharedObjectEventType type) { switch (type) { case SharedObjectEventType.SERVER_CONNECT: return("server connect"); case SharedObjectEventType.SERVER_DISCONNECT: return("server disconnect"); case SharedObjectEventType.SERVER_SET_ATTRIBUTE: return("server_set_attribute"); case SharedObjectEventType.SERVER_DELETE_ATTRIBUTE: return("server_delete_attribute"); case SharedObjectEventType.SERVER_SEND_MESSAGE: return("server_send_message"); case SharedObjectEventType.CLIENT_CLEAR_DATA: return("client_clear_data"); case SharedObjectEventType.CLIENT_DELETE_DATA: return("client_delete_data"); case SharedObjectEventType.CLIENT_INITIAL_DATA: return("client_initial_data"); case SharedObjectEventType.CLIENT_STATUS: return("client_status"); case SharedObjectEventType.CLIENT_UPDATE_DATA: return("client_update_data"); case SharedObjectEventType.CLIENT_UPDATE_ATTRIBUTE: return("client_update_attribute"); case SharedObjectEventType.CLIENT_SEND_MESSAGE: return("client_send_message"); } return("unknown"); }
public static byte ToByte(SharedObjectEventType type) { switch (type) { case SharedObjectEventType.SERVER_CONNECT: return(1); case SharedObjectEventType.SERVER_DISCONNECT: return(2); case SharedObjectEventType.SERVER_SET_ATTRIBUTE: return(3); case SharedObjectEventType.SERVER_DELETE_ATTRIBUTE: return(10); case SharedObjectEventType.SERVER_SEND_MESSAGE: return(6); case SharedObjectEventType.CLIENT_CLEAR_DATA: return(8); case SharedObjectEventType.CLIENT_DELETE_DATA: return(9); case SharedObjectEventType.CLIENT_INITIAL_DATA: return(11); case SharedObjectEventType.CLIENT_STATUS: return(7); case SharedObjectEventType.CLIENT_UPDATE_DATA: return(4); case SharedObjectEventType.CLIENT_UPDATE_ATTRIBUTE: return(5); case SharedObjectEventType.CLIENT_SEND_MESSAGE: return(6); } return(0); }
/// <summary> /// Initializes a new instance of the SharedObjectEvent class with the given initial value. /// </summary> /// <param name="type">Type of the event.</param> /// <param name="key">Key of the event.</param> /// <param name="value">Value of the event.</param> public SharedObjectEvent(SharedObjectEventType type, String key, Object value) { _type = type; _key = key; _value = value; }
/// <summary> /// Add a shared object event. /// </summary> /// <param name="type">Event type.</param> /// <param name="key">Handler key.</param> /// <param name="value">Event value.</param> public void AddEvent(SharedObjectEventType type, string key, object value) { _events.Enqueue(new SharedObjectEvent(type, key, value)); }
static void DecodeSharedObject(SharedObjectMessage so, ByteBuffer stream, RtmpReader reader) { // Parse request body while (stream.HasRemaining) { byte typeCode = reader.ReadByte(); SharedObjectEventType type = SharedObjectTypeMapping.ToType(typeCode); string key = null; object value = null; int length = stream.GetInt(); //reader.ReadInt32(); switch (type) { case SharedObjectEventType.CLIENT_STATUS: // Status code key = reader.ReadString(); // Status level value = reader.ReadString(); break; case SharedObjectEventType.CLIENT_UPDATE_DATA: { key = reader.ReadString(); value = reader.ReadData(); /* * key = null; * // Map containing new attribute values * Hashtable map = new Hashtable(); * int start = (int)stream.Position; * while((int)stream.Position - start < length) * { * string tmp = reader.ReadString(); * map[tmp] = reader.ReadData(); * } * value = map; */ } break; default: if (type != SharedObjectEventType.SERVER_SEND_MESSAGE && type != SharedObjectEventType.CLIENT_SEND_MESSAGE) { if (length > 0) { key = reader.ReadString(); if (length > key.Length + 2) { value = reader.ReadData(); } } } else { int start = (int)stream.Position; // the "send" event seems to encode the handler name // as complete AMF string including the string type byte key = reader.ReadData() as string; // read parameters #if !(NET_1_1) List <object> paramList = new List <object>(); #else ArrayList paramList = new ArrayList(); #endif while (stream.Position - start < length) { object tmp = reader.ReadData(); paramList.Add(tmp); } value = paramList; } break; } so.AddEvent(type, key, value); } }
public void AddEvent(SharedObjectEventType type, string key, object value) { this._events.Add(new SharedObjectEvent(type, key, value)); }
public SharedObjectEvent(SharedObjectEventType type, string key, object value) { this._type = type; this._key = key; this._value = value; }