protected void handleInteropMessage(KLFCommon.PluginInteropMessageID id, byte[] data)
{
switch (id)
{
case KLFCommon.PluginInteropMessageID.CHAT_SEND:
if (data != null)
{
String line = encoder.GetString(data);
InTextMessage message = new InTextMessage();
message.fromServer = false;
message.message = "[" + clientSettings.username + "] " + line;
enqueueTextMessage(message, false);
handleChatInput(line);
}
break;
case KLFCommon.PluginInteropMessageID.PLUGIN_DATA:
String new_watch_player_name = String.Empty;
if (data != null && data.Length >= 9)
{
UnicodeEncoding encoder = new UnicodeEncoding();
int index = 0;
//Read current activity status
bool in_flight = data[index] != 0;
index++;
//Read current game title
int current_game_title_length = KLFCommon.intFromBytes(data, index);
index += 4;
currentGameTitle = encoder.GetString(data, index, current_game_title_length);
index += current_game_title_length;
//Send the activity status to the server
if (in_flight)
sendMessageTCP(KLFCommon.ClientMessageID.ACTIVITY_UPDATE_IN_FLIGHT, null);
else
sendMessageTCP(KLFCommon.ClientMessageID.ACTIVITY_UPDATE_IN_GAME, null);
}
break;
case KLFCommon.PluginInteropMessageID.PRIMARY_PLUGIN_UPDATE:
sendPluginUpdate(data, true);
break;
case KLFCommon.PluginInteropMessageID.SECONDARY_PLUGIN_UPDATE:
sendPluginUpdate(data, false);
break;
case KLFCommon.PluginInteropMessageID.SCREENSHOT_SHARE:
if (data != null)
{
lock (screenshotOutLock)
{
queuedOutScreenshot = data;
}
}
break;
case KLFCommon.PluginInteropMessageID.SCREENSHOT_WATCH_UPDATE:
if (data != null && data.Length >= 8)
{
int index = KLFCommon.intFromBytes(data, 0);
int current_index = KLFCommon.intFromBytes(data, 4);
String name = encoder.GetString(data, 8, data.Length - 8);
if (watchPlayerName != name || watchPlayerIndex != index)
{
watchPlayerName = name;
watchPlayerIndex = index;
//Look in the screenshot cache for the requested screenshot
Screenshot cached = getCachedScreenshot(watchPlayerIndex, watchPlayerName);
if (cached != null)
sendClientInteropMessage(KLFCommon.ClientInteropMessageID.SCREENSHOT_RECEIVE, cached.toByteArray());
sendScreenshotWatchPlayerMessage((cached == null), current_index, watchPlayerIndex, watchPlayerName);
}
}
break;
}
}