<commit_before>//     telegram-mt-node
//     Copyright 2014 <NAME> '<EMAIL>'
//     Released under the MIT License
//     https://github.com/enricostara/telegram-mt-node

//     EncryptedRpcChannel class
//
// This class provides an encrypted remote procedure call channel to `Telegram` through the given TCP|HTTP connection.
// This channel in  encrypted and therefore use EncryptedMessage objects to wrap the communication.

// Import dependencies
require('requirish')._(module);
var RpcChannel = require('lib/net').RpcChannel;
var message = require('lib/message');
var mtproto = require('lib/mtproto');
var logger = require('get-log')('net.EncryptedRpcChannel');

// EncryptedRpcChannel extends RpcChannel
require('util').inherits(EncryptedRpcChannel, RpcChannel);

// The constructor require the following:
// - [Http|Tcp]Connection, the connection must be already open.
// - all the client data required for execute the first API call to Telegram (Optional):
// { apiVersion, appId, appVersion, deviceModel, systemVersion, langCode }

function EncryptedRpcChannel(connection, clientData) {
    this.constructor.super_.call(this, connection);
    this._initClientData = clientData;
}

// Execute remotely the given method (Type function) using the following context params:
// { authKey, serverSalt, sessionId, sequenceNumber }
EncryptedRpcChannel.prototype.callMethod = function(method, context, callback) {
    if (!this._open) {
        callback(new Error('Channel is closed'));
        return;
    }
    var methodBytes;
    if (this._initClientData) {
        method = new mtproto.service.invokeWithLayer.Type({<commit_msg>Remove unused line<commit_after>//     telegram-mt-node
//     Copyright 2014 <NAME> '<EMAIL>'
//     Released under the MIT License
//     https://github.com/enricostara/telegram-mt-node

//     EncryptedRpcChannel class
//
// This class provides an encrypted remote procedure call channel to `Telegram` through the given TCP|HTTP connection.
// This channel in  encrypted and therefore use EncryptedMessage objects to wrap the communication.

// Import dependencies
require('requirish')._(module);
var RpcChannel = require('lib/net').RpcChannel;
var message = require('lib/message');
var mtproto = require('lib/mtproto');
var logger = require('get-log')('net.EncryptedRpcChannel');

// EncryptedRpcChannel extends RpcChannel
require('util').inherits(EncryptedRpcChannel, RpcChannel);

// The constructor require the following:
// - [Http|Tcp]Connection, the connection must be already open.
// - all the client data required for execute the first API call to Telegram (Optional):
// { apiVersion, appId, appVersion, deviceModel, systemVersion, langCode }

function EncryptedRpcChannel(connection, clientData) {
    this.constructor.super_.call(this, connection);
    this._initClientData = clientData;
}

// Execute remotely the given method (Type function) using the following context params:
// { authKey, serverSalt, sessionId, sequenceNumber }
EncryptedRpcChannel.prototype.callMethod = function(method, context, callback) {
    if (!this._open) {
        callback(new Error('Channel is closed'));
        return;
    }
    if (this._initClientData) {
        method = new mtproto.service.invokeWithLayer.Type({
{'fraction_non_alphanumeric': 0.11107692307692307, 'fraction_numerical': 0.0024615384615384616, 'mean_word_length': 4.286178861788618, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '6865752', 'n_tokens_mistral': 891, 'n_tokens_neox': 876, 'n_words': 271}