<commit_before>package org.protobee.examples.broadcast.modules;

import java.net.SocketAddress;

import org.jboss.netty.handler.codec.http.HttpMethod;
import org.protobee.annotation.InjectLogger;
import org.protobee.compatability.Headers;
import org.protobee.events.BasicMessageReceivedEvent;
import org.protobee.examples.protos.BroadcasterProtos.BroadcastMessage;
import org.protobee.guice.scopes.SessionScope;
import org.protobee.identity.NetworkIdentityManager;
import org.protobee.modules.ProtocolModule;
import org.protobee.network.ConnectionCreator;
import org.protobee.protocol.Protocol;
import org.protobee.protocol.ProtocolModel;
import org.protobee.util.SocketAddressUtils;
import org.slf4j.Logger;

import com.google.common.base.Preconditions;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Inject;

@SessionScope
@Headers(required = {})
public class FeelingsInitiatorModule extends ProtocolModule {

  @InjectLogger
  private Logger log;
  private final NetworkIdentityManager identityManager;
  private final Protocol feelingsProtocol;
  private final ConnectionCreator creator;
  private final ProtocolModel feelingsModel;
  private final SocketAddressUtils addressUtils;

  @Inject
  public FeelingsInitiatorModule(ConnectionCreator creator,
      Protocol feelings, ProtocolModel feelingsModel, SocketAddressUtils addressUtils,
      NetworkIdentityManager manager) {
    this.creator = creator;
    this.feelingsProtocol = feelings;
    this.feelingsModel = feelingsModel;
    this.addressUtils = addressUtils;
    this.identityManager = manager;
  }

  @Subscribe
  public void messageReceived(BasicMessageReceivedEvent event) {
    Preconditions.checkArgument(event.getMessage() instanceof BroadcastMessage,
        "Not a broadcast message");
    BroadcastMessage message = (BroadcastMessage) event.getMessage();
    SocketAddress address =
        addressUtils.getAddress(message.getListeningAddress(), message.getListeningPort());
    if (message.getMessage().equals("feelings!")
        && (!identityManager.hasNetworkIdentity(address) || !identityManager.getNewtorkIdentity(
            address).hasCurrentSession(feelingsProtocol))) {
      log.info("Connecting to address " + address + " with feelings protocol");
      creator.connect(feelingsModel, address, HttpMethod.valueOf("SAY"), "/");
    }
  }
}
<commit_msg>fixed feelings initiator<commit_after>package org.protobee.examples.broadcast.modules;

import java.net.SocketAddress;

import org.jboss.netty.handler.codec.http.HttpMethod;
import org.protobee.annotation.InjectLogger;
import org.protobee.compatability.Headers;
import org.protobee.events.BasicMessageReceivedEvent;
import org.protobee.examples.emotion.Emotion;
import org.protobee.examples.protos.BroadcasterProtos.BroadcastMessage;
import org.protobee.guice.scopes.SessionScope;
import org.protobee.identity.NetworkIdentityManager;
import org.protobee.modules.ProtocolModule;
import org.protobee.network.ConnectionCreator;
import org.protobee.protocol.Protocol;
import org.protobee.protocol.ProtocolModel;
import org.protobee.util.SocketAddressUtils;
import org.slf4j.Logger;

import com.google.common.base.Preconditions;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Inject;

@SessionScope
@Headers(required = {})
public class FeelingsInitiatorModule extends ProtocolModule {

  @InjectLogger
  private Logger log;
  private final NetworkIdentityManager identityManager;
  private final Protocol feelingsProtocol;
  private final ConnectionCreator creator;
  private final ProtocolModel feelingsModel;
  private final SocketAddressUtils addressUtils;

  @Inject
  public FeelingsInitiatorModule(ConnectionCreator creator,
      @Emotion Protocol feelings, @Emotion ProtocolModel feelingsModel, SocketAddressUtils addressUtils,
      NetworkIdentityManager manager) {
    this.creator = creator;
    this.feelingsProtocol = feelings;
    this.feelingsModel = feelingsModel;
    this.addressUtils = addressUtils;
    this.identityManager = manager;
  }

  @Subscribe
  public void messageReceived(BasicMessageReceivedEvent event) {
    Preconditions.checkArgument(event.getMessage() instanceof BroadcastMessage,
        "Not a broadcast message");
    BroadcastMessage message = (BroadcastMessage) event.getMessage();
    SocketAddress address =
        addressUtils.getAddress(message.getListeningAddress(), message.getListeningPort());
    if (message.getMessage().equals("feelings!")
        && (!identityManager.hasNetworkIdentity(address) || !identityManager.getNewtorkIdentity(
            address).hasCurrentSession(feelingsProtocol))) {
      log.info("Connecting to address " + address + " with feelings protocol");
      creator.connect(feelingsModel, address, HttpMethod.valueOf("SAY"), "/");
    }
  }
}

{'fraction_non_alphanumeric': 0.08924485125858124, 'fraction_numerical': 0.00041605991262741833, 'mean_word_length': 5.541496598639456, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1121109', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1293, 'n_words': 254}