<commit_before>module Protocols
  module WebSockets
    class ChatConnection
      # Public: Connection socket
      attr_reader :socket

      # Public: Connection user
      attr_reader :user

      # Publci: Connection room
      attr_reader :room

      # Public: Initialize the connection instance
      def initialize(socket)
        @socket = socket
      end

      # Public: Event triggered when the connection is opened
      #
      # Returns nothing
      def onopen
      end

      # Public: Event triggered when the connection is closed
      #
      # Returns nothing
      def onclose
      end

      # Public: Event triggered when data is transmitted through the connection
      #
      # data - String of data
      #
      # Returns nothing
      def onmessage(data)
      end
    end
  end
end<commit_msg>Basic websocket connection methods<commit_after>module Protocols
  module WebSockets
    class ChatConnection
      # Public: Connection socket
      attr_reader :socket

      # Public: Connection user
      attr_reader :user

      # Public: Initialize the connection instance
      def initialize(socket)
        @socket = socket
      end

      # Public: Event triggered when the connection is opened
      #
      # Returns nothing
      def onopen
        @user = User.new 0, "Guest", "<EMAIL>", 1, "000000", false
      end

      # Public: Event triggered when the connection is closed
      #
      # Returns nothing
      def onclose
      end

      # Public: Event triggered when data is transmitted through the connection
      #
      # data - String of data
      #
      # Returns nothing
      def onmessage(data)
        message = Message.new { :type => :text, :text => data, :user => @user }
        message.execute! if message.executable?
        @socket.send message.to_json unless message.public?
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.058133333333333335, 'fraction_numerical': 0.004266666666666667, 'mean_word_length': 2.0754098360655737, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 7, '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': '1544530', 'n_tokens_mistral': 484, 'n_tokens_neox': 461, 'n_words': 178}