<commit_before>%%
%% Copyright (c) 2015 <NAME>
%%
%% Permission is hereby granted, free of charge, to any person obtaining a copy
%% of this software and associated documentation files (the "Software"), to deal
%% in the Software without restriction, including without limitation the rights
%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
%% copies of the Software, and to permit persons to whom the Software is
%% furnished to do so, subject to the following conditions:
%%
%% The above copyright notice and this permission notice shall be included in all
%% copies or substantial portions of the Software.
%%
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
%% SOFTWARE.
%%

-module(erwa_routing).

-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.

-export([create/0]).
-export([
        set_peer/2,
        set_ssl/2,
        set_source/2,
        set_id/2,
        set_trans/2
        ]).
-export([
        get_peer/1,
        get_ssl/1,
        get_source/1,
        get_id/1,
        get_mwl/1,
	get_authid/1,
	get_role/1,
  get_trans/1
        ]).
-export([handle_message/2]).
-export([handle_info/2]).


-record(state, {
                id = none,
                is_auth = false,
                realm_name = none,
                mwl = [],
                client_roles = unknown,
                source = unknown,
                peer = unknown,
                ssl = false,
                trans = unknown,
                goodbye_sent = false,
                calls = [],
                session_data = #{},
                authid = anonymous,
                role = guest,
                will_pass = false,
                invocation_id = 1,
                invocations = []
                }).


-define(BROKER_FEATURES,#{features => #{
					 event_history => false,
					 partitioned_pubsub => false,
					 pattern_based_subscription => false,
					 publication_trustlevels => false,
					 publisher_exclusion => true,
					 publisher_identification => true,
					 subscriber_blackwhite_listing => true,
					 subscriber_list => false,
					 subscriber_metaevents => false
					}

				  }
	   ).

-define(DEALER_FEATURES,#{features => #{
                                 call_canceling =>             true,
                                 call_timeout =>               true,
                                 call_trustlevels =>           false,
                                 callee_blackwhite_listing =>  false,
                                 caller_exclusion =>           false,
                                 caller_identification =>      false,
                                 partitioned_rpc =>            false,
                                 pattern_based_registration => false,
                                 progressive_call_results =>   true
                                 }

                   }
        ).


-define(ROLES, #{ 
		  broker => ?BROKER_FEATURES,
		  dealer => ?DEALER_FEATURES
				}).

%
% Session Scope IDs
%
%     ERROR.Request
%     PUBLISH.Request
%     PUBLISHED.Request
%     SUBSCRIBE.Request
%     SUBSCRIBED.Request
%     UNSUBSCRIBE.Request
%     UNSUBSCRIBED.Request
%     CALL.Request
%     CANCEL.Request
%     RESULT.Request
%     REGISTER.Request
%     REGISTERED.Request
%     UNREGISTER.Request
%     UNREGISTERED.Request
%     INVOCATION.Request
%     INTERRUPT.Request
%     YIELD.Request
%
% IDs in the session scope SHOULD be incremented by 1 beginning with 1
% (for each direction - Client-to-Router and Router-to-Client)
%


create() ->
  #state{}.

set_peer(Peer,State) ->
  State#state{peer=Peer}.

set_source(Source,State) ->
  State#state{source=Source}.

set_ssl(SSL,State) ->
  State#state{ssl=SSL}.

set_trans(Transport, State) ->
  State#state{trans=Transport}.
<commit_msg>Rename create to init<commit_after>%%
%% Copyright (c) 2015 <NAME>
%%
%% Permission is hereby granted, free of charge, to any person obtaining a copy
%% of this software and associated documentation files (the "Software"), to deal
%% in the Software without restriction, including without limitation the rights
%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
%% copies of the Software, and to permit persons to whom the Software is
%% furnished to do so, subject to the following conditions:
%%
%% The above copyright notice and this permission notice shall be included in all
%% copies or substantial portions of the Software.
%%
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
%% SOFTWARE.
%%

-module(erwa_routing).

-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.

-export([init/0]).
-export([
        set_peer/2,
        set_ssl/2,
        set_source/2,
        set_id/2,
        set_trans/2
        ]).
-export([
        get_peer/1,
        get_ssl/1,
        get_source/1,
        get_id/1,
        get_mwl/1,
	get_authid/1,
	get_role/1,
  get_trans/1
        ]).
-export([handle_message/2]).
-export([handle_info/2]).


-record(state, {
                id = none,
                is_auth = false,
                realm_name = none,
                mwl = [],
                client_roles = unknown,
                source = unknown,
                peer = unknown,
                ssl = false,
                trans = unknown,
                goodbye_sent = false,
                calls = [],
                session_data = #{},
                authid = anonymous,
                role = guest,
                will_pass = <PASSWORD>,
                invocation_id = 1,
                invocations = []
                }).


-define(BROKER_FEATURES,#{features => #{
					 event_history => false,
					 partitioned_pubsub => false,
					 pattern_based_subscription => false,
					 publication_trustlevels => false,
					 publisher_exclusion => true,
					 publisher_identification => true,
					 subscriber_blackwhite_listing => true,
					 subscriber_list => false,
					 subscriber_metaevents => false
					}

				  }
	   ).

-define(DEALER_FEATURES,#{features => #{
                                 call_canceling =>             true,
                                 call_timeout =>               true,
                                 call_trustlevels =>           false,
                                 callee_blackwhite_listing =>  false,
                                 caller_exclusion =>           false,
                                 caller_identification =>      false,
                                 partitioned_rpc =>            false,
                                 pattern_based_registration => false,
                                 progressive_call_results =>   true
                                 }

                   }
        ).


-define(ROLES, #{ 
		  broker => ?BROKER_FEATURES,
		  dealer => ?DEALER_FEATURES
				}).

%
% Session Scope IDs
%
%     ERROR.Request
%     PUBLISH.Request
%     PUBLISHED.Request
%     SUBSCRIBE.Request
%     SUBSCRIBED.Request
%     UNSUBSCRIBE.Request
%     UNSUBSCRIBED.Request
%     CALL.Request
%     CANCEL.Request
%     RESULT.Request
%     REGISTER.Request
%     REGISTERED.Request
%     UNREGISTER.Request
%     UNREGISTERED.Request
%     INVOCATION.Request
%     INTERRUPT.Request
%     YIELD.Request
%
% IDs in the session scope SHOULD be incremented by 1 beginning with 1
% (for each direction - Client-to-Router and Router-to-Client)
%


init() ->
  #state{}.

set_peer(Peer,State) ->
  State#state{peer=Peer}.

set_source(Source,State) ->
  State#state{source=Source}.

set_ssl(SSL,State) ->
  State#state{ssl=SSL}.

set_trans(Transport, State) ->
  State#state{trans=Transport}.

{'fraction_non_alphanumeric': 0.09390892962743938, 'fraction_numerical': 0.005440567711413365, 'mean_word_length': 1.8337801608579087, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6233766', 'n_tokens_mistral': 2523, 'n_tokens_neox': 2276, 'n_words': 629}