<commit_before>package peote.net;

import haxe.io.Bytes;

/**
 * by <NAME> - Rostock 2015
 *  --- joint protocol ---
 */

import peote.socket.PeoteSocket;

class PeoteJointSocket
{

	var peoteSocket:PeoteSocket;
	
	var connected:Bool = false;
	
	var onConnectCallback:Bool -> String -> Void;
	var onCloseCallback:String -> Void;
	var onErrorCallback:String -> Void;
	
	
	var ownJointDataCallback:Map<Int,Int -> Int -> Bytes -> Void>;
	var inJointDataCallback :Map<Int,Int -> Bytes -> Void> ;
	
	var ownUserConnectCallback   :Map<Int,Bytes -> Void> ;
	var ownUserDisconnectCallback:Map<Int,Bytes -> Void> ;
	var inDisconnectCallback     :Map<Int,Bytes -> Void>;
	
	var waitingCommandCallbacks:Map<Int,Bytes -> Void> ;
	
	var input:Bytes;
	var input_pos:Int = 0;
	var input_end:Int = 0;
	
	var bytes_left:Int = 0;
	var command_mode:Bool = false;
	var joint_nr:Int = -1;
	var user_nr:Int = -1;
	
	
	public function new(server:String, port: Int,
						onConnectCallback:Bool -> String -> Void = null,
						onCloseCallback:String -> Void = null,
						onErrorCallback:String -> Void = null
						) 
	{
		this.onConnectCallback = onConnectCallback;
		this.onCloseCallback = onCloseCallback;
		this.onErrorCallback = onErrorCallback;
		
		input = Bytes.alloc((32767+2)*2); // TODO -> let grow dynamic!!!
		
		ownJointDataCallback = new Map<Int,Int -> Int -> Bytes -> Void>();
		inJointDataCallback  = new Map<Int,Int -> Bytes -> Void>();
		
		ownUserConnectCallback    = new Map<Int,Bytes -> Void>() ;
		ownUserDisconnectCallback = new Map<Int,Bytes -> Void>() ;<commit_msg>increase buffersize for better testing (todo)<commit_after>package peote.net;

import haxe.io.Bytes;

/**
 * by <NAME> - Rostock 2015
 *  --- joint protocol ---
 */

import peote.socket.PeoteSocket;

class PeoteJointSocket
{

	var peoteSocket:PeoteSocket;
	
	var connected:Bool = false;
	
	var onConnectCallback:Bool -> String -> Void;
	var onCloseCallback:String -> Void;
	var onErrorCallback:String -> Void;
	
	
	var ownJointDataCallback:Map<Int,Int -> Int -> Bytes -> Void>;
	var inJointDataCallback :Map<Int,Int -> Bytes -> Void> ;
	
	var ownUserConnectCallback   :Map<Int,Bytes -> Void> ;
	var ownUserDisconnectCallback:Map<Int,Bytes -> Void> ;
	var inDisconnectCallback     :Map<Int,Bytes -> Void>;
	
	var waitingCommandCallbacks:Map<Int,Bytes -> Void> ;
	
	var input:Bytes;
	var input_pos:Int = 0;
	var input_end:Int = 0;
	
	var bytes_left:Int = 0;
	var command_mode:Bool = false;
	var joint_nr:Int = -1;
	var user_nr:Int = -1;
	
	
	public function new(server:String, port: Int,
						onConnectCallback:Bool -> String -> Void = null,
						onCloseCallback:String -> Void = null,
						onErrorCallback:String -> Void = null
						) 
	{
		this.onConnectCallback = onConnectCallback;
		this.onCloseCallback = onCloseCallback;
		this.onErrorCallback = onErrorCallback;
		
		input = Bytes.alloc((32767+2)*256); // TODO -> let grow dynamic!!!
		
		ownJointDataCallback = new Map<Int,Int -> Int -> Bytes -> Void>();
		inJointDataCallback  = new Map<Int,Int -> Bytes -> Void>();
		
		ownUserConnectCallback    = new Map<Int,Bytes -> Void>() ;
		ownUserDisconnectCallback = new Map<Int,Bytes -> Void>() ;
{'fraction_non_alphanumeric': 0.13123028391167194, 'fraction_numerical': 0.010725552050473186, 'mean_word_length': 3.7047477744807122, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 75, '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': '7302714', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1017, 'n_words': 243}