skadistats/clarity-examples

Is the allchat example still relevant?

larry-barry opened this issue · 1 comments

package example.parser.allchat;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import skadistats.clarity.processor.reader.OnMessage;
import skadistats.clarity.processor.runner.Context;
import skadistats.clarity.wire.s2.proto.S2UserMessages;

public class AllChatProcessor {
    private final Logger log = LoggerFactory.getLogger(Main.class.getPackage().getClass());

    @OnMessage(S2UserMessages.CUserMessageSayText2.class)
    public void onMessage(Context ctx, S2UserMessages.CUserMessageSayText2 message) {
        log.info("%s: %s\n", message.getParam1(), message.getParam2());
    }   
}
package example.parser.allchat;

import skadistats.clarity.processor.entities.UsesEntities;
import skadistats.clarity.processor.runner.SimpleRunner;
import skadistats.clarity.source.MappedFileSource;


@UsesEntities
public class Main {

    public void run(String[] args) throws Exception {
        SimpleRunner runner = new SimpleRunner(new MappedFileSource(args[0]));
        AllChatProcessor processor = new AllChatProcessor();
        runner.runWith(processor);
    }

    public static void main(String[] args) throws Exception {
        new Main().run(args);
    }

}

Yields the following:

➜  dota java -jar target/allchat.one-jar.jar replay.dem
14:48:33.415 [main] DEBUG clarity.execution - require processor skadistats.clarity.processor.runner.SimpleRunner
14:48:33.430 [main] DEBUG clarity.execution - require processor skadistats.clarity.model.engine.DotaS2EngineType
14:48:33.450 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.sendtables.DTClasses
14:48:33.452 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.reader.InputSourceProcessor
14:48:33.456 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.stringtables.S1StringTableEmitter
14:48:33.460 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.gameevents.CombatLog
14:48:33.460 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.runner.AbstractRunner
14:48:33.461 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.sendtables.S2DTClassEmitter
14:48:33.462 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.entities.PropertyChange
14:48:33.463 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.packet.PacketReader
14:48:33.463 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.modifiers.Modifiers
14:48:33.464 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.stringtables.StringTables
14:48:33.465 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.runner.AbstractFileRunner
14:48:33.466 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.stringtables.PlayerInfo
14:48:33.468 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.entities.Entities
14:48:33.471 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.stringtables.S2StringTableEmitter
14:48:33.472 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.sendtables.S1DTClassEmitter
14:48:33.472 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.gameevents.GameEvents
14:48:33.474 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.tempentities.TempEntities
14:48:33.474 [main] DEBUG clarity.execution - provider found on ClassIndex: skadistats.clarity.processor.resources.Resources
14:48:33.475 [main] DEBUG clarity.execution - require processor skadistats.clarity.processor.packet.PacketReader
14:48:33.475 [main] DEBUG clarity.execution - require processor skadistats.clarity.source.MappedFileSource
14:48:33.475 [main] DEBUG clarity.execution - require processor example.parser.allchat.AllChatProcessor
14:48:33.477 [main] DEBUG clarity.execution - require event listener interface skadistats.clarity.processor.reader.OnMessage
14:48:33.477 [main] DEBUG clarity.execution - require processor skadistats.clarity.processor.reader.InputSourceProcessor
14:48:33.481 [main] DEBUG clarity.execution - register initializer interface skadistats.clarity.processor.reader.OnMessage
14:48:33.481 [main] DEBUG clarity.execution - register initializer interface skadistats.clarity.processor.reader.OnPostEmbeddedMessage
14:48:33.481 [main] DEBUG clarity.execution - register initializer interface skadistats.clarity.processor.reader.OnMessageContainer
14:48:33.481 [main] DEBUG clarity.execution - require event listener interface skadistats.clarity.processor.runner.OnInputSource
14:48:33.481 [main] DEBUG clarity.execution - require event listener interface skadistats.clarity.processor.reader.OnMessageContainer
14:48:33.481 [main] DEBUG clarity.execution - require event listener interface skadistats.clarity.processor.reader.OnMessage
14:48:33.484 [main] DEBUG clarity.execution - bind public void skadistats.clarity.processor.reader.InputSourceProcessor.processEmbedded(java.lang.Class,com.google.protobuf.ByteString) throws java.io.IOException to context
14:48:33.488 [main] DEBUG clarity.execution - bind public void skadistats.clarity.processor.reader.InputSourceProcessor.initOnPostEmbeddedMessageListener(skadistats.clarity.event.EventListener) to context
14:48:33.490 [main] DEBUG clarity.execution - bind public void skadistats.clarity.processor.reader.InputSourceProcessor.processSource(skadistats.clarity.source.Source,skadistats.clarity.processor.runner.LoopController) throws java.lang.Exception to context
14:48:33.490 [main] DEBUG clarity.execution - bind public void skadistats.clarity.processor.reader.InputSourceProcessor.initOnMessageContainerListener(skadistats.clarity.event.EventListener) to context
14:48:33.490 [main] DEBUG clarity.execution - bind public void example.parser.allchat.AllChatProcessor.onMessage(skadistats.clarity.processor.runner.Context,skadistats.clarity.wire.s2.proto.S2UserMessages$CUserMessageSayText2) to context
14:48:33.491 [main] DEBUG clarity.execution - bind public void skadistats.clarity.processor.reader.InputSourceProcessor.processServerInfo(skadistats.clarity.wire.common.proto.NetMessages$CSVCMsg_ServerInfo) to context
14:48:33.492 [main] DEBUG clarity.execution - bind public void skadistats.clarity.processor.reader.InputSourceProcessor.initOnMessageListener(skadistats.clarity.event.EventListener) to context

I derived this from the example on the README.md but can't seem to get this to work.

Just tried the example and it works.
@UsesEntities is not needed, chat works without.
Set a breakpoint at the line where you output the chat message, and see if it reaches there. Maybe your logging is just mis-configured.