How to use disconnectClient method in Best

Best JavaScript code snippet using best

index.js

Source:index.js Github

copy

Full Screen

1'use strict';2const MongoBench = require('../mongoBench');3const Runner = MongoBench.Runner;4const commonHelpers = require('./common');5const BSON = require('bson');6const { EJSON } = require('bson');7const makeClient = commonHelpers.makeClient;8const connectClient = commonHelpers.connectClient;9const disconnectClient = commonHelpers.disconnectClient;10const initDb = commonHelpers.initDb;11const dropDb = commonHelpers.dropDb;12const createCollection = commonHelpers.createCollection;13const initCollection = commonHelpers.initCollection;14const dropCollection = commonHelpers.dropCollection;15const makeLoadJSON = commonHelpers.makeLoadJSON;16const loadSpecString = commonHelpers.loadSpecString;17const loadSpecFile = commonHelpers.loadSpecFile;18const initBucket = commonHelpers.initBucket;19const dropBucket = commonHelpers.dropBucket;20function average(arr) {21 return arr.reduce((x, y) => x + y, 0) / arr.length;22}23function encodeBSON() {24 for (let i = 0; i < 10000; i += 1) {25 BSON.serialize(this.dataString);26 }27}28function decodeBSON() {29 for (let i = 0; i < 10000; i += 1) {30 BSON.deserialize(this.data);31 }32}33function makeBSONLoader(fileName) {34 return function () {35 this.dataString = EJSON.parse(loadSpecString(['extended_bson', `${fileName}.json`]));36 this.data = BSON.serialize(this.dataString);37 };38}39function loadGridFs() {40 this.bin = loadSpecFile(['single_and_multi_document', 'gridfs_large.bin']);41}42function makeTestInsertOne(numberOfOps) {43 return function (done) {44 const loop = _id => {45 if (_id > numberOfOps) {46 return done();47 }48 const doc = Object.assign({}, this.doc);49 this.collection.insertOne(doc, err => (err ? done(err) : loop(_id + 1)));50 };51 loop(1);52 };53}54function makeLoadTweets(makeId) {55 return function () {56 const doc = this.doc;57 const tweets = [];58 for (let _id = 1; _id <= 10000; _id += 1) {59 tweets.push(Object.assign({}, doc, makeId ? { _id } : {}));60 }61 return this.collection.insertMany(tweets);62 };63}64function makeLoadInsertDocs(numberOfOperations) {65 return function () {66 this.docs = [];67 for (let i = 0; i < numberOfOperations; i += 1) {68 this.docs.push(Object.assign({}, this.doc));69 }70 };71}72function findOneById(done) {73 const loop = _id => {74 if (_id > 10000) {75 return done();76 }77 return this.collection.findOne({ _id }, err => (err ? done(err) : loop(_id + 1)));78 };79 return loop(1);80}81function runCommand(done) {82 const loop = _id => {83 if (_id > 10000) {84 return done();85 }86 return this.db.command({ ismaster: true }, err => (err ? done(err) : loop(_id + 1)));87 };88 return loop(1);89}90function findManyAndEmptyCursor(done) {91 return this.collection.find({}).forEach(() => {}, done);92}93function docBulkInsert(done) {94 return this.collection.insertMany(this.docs, { ordered: true }, done);95}96function gridFsInitUploadStream() {97 this.stream = this.bucket.openUploadStream('gridfstest');98}99function writeSingleByteToUploadStream() {100 return new Promise((resolve, reject) => {101 this.stream.write('\0', null, err => (err ? reject(err) : resolve()));102 });103}104const benchmarkRunner = new Runner()105 .suite('bsonBench', suite =>106 suite107 .benchmark('flatBsonEncoding', benchmark =>108 benchmark.taskSize(75.31).setup(makeBSONLoader('flat_bson')).task(encodeBSON)109 )110 .benchmark('flatBsonDecoding', benchmark =>111 benchmark.taskSize(75.31).setup(makeBSONLoader('flat_bson')).task(decodeBSON)112 )113 .benchmark('deepBsonEncoding', benchmark =>114 benchmark.taskSize(19.64).setup(makeBSONLoader('deep_bson')).task(encodeBSON)115 )116 .benchmark('deepBsonDecoding', benchmark =>117 benchmark.taskSize(19.64).setup(makeBSONLoader('deep_bson')).task(decodeBSON)118 )119 .benchmark('fullBsonEncoding', benchmark =>120 benchmark.taskSize(57.34).setup(makeBSONLoader('full_bson')).task(encodeBSON)121 )122 .benchmark('fullBsonDecoding', benchmark =>123 benchmark.taskSize(57.34).setup(makeBSONLoader('full_bson')).task(decodeBSON)124 )125 )126 .suite('singleBench', suite =>127 suite128 .benchmark('runCommand', benchmark =>129 benchmark130 .taskSize(0.16)131 .setup(makeClient)132 .setup(connectClient)133 .setup(initDb)134 .task(runCommand)135 .teardown(disconnectClient)136 )137 .benchmark('findOne', benchmark =>138 benchmark139 .taskSize(16.22)140 .setup(makeLoadJSON('tweet.json'))141 .setup(makeClient)142 .setup(connectClient)143 .setup(initDb)144 .setup(dropDb)145 .setup(initCollection)146 .setup(makeLoadTweets(true))147 .task(findOneById)148 .teardown(dropDb)149 .teardown(disconnectClient)150 )151 .benchmark('smallDocInsertOne', benchmark =>152 benchmark153 .taskSize(2.75)154 .setup(makeLoadJSON('small_doc.json'))155 .setup(makeClient)156 .setup(connectClient)157 .setup(initDb)158 .setup(dropDb)159 .setup(initDb)160 .setup(initCollection)161 .setup(createCollection)162 .beforeTask(dropCollection)163 .beforeTask(createCollection)164 .beforeTask(initCollection)165 .task(makeTestInsertOne(10000))166 .teardown(dropDb)167 .teardown(disconnectClient)168 )169 .benchmark('largeDocInsertOne', benchmark =>170 benchmark171 .taskSize(27.31)172 .setup(makeLoadJSON('large_doc.json'))173 .setup(makeClient)174 .setup(connectClient)175 .setup(initDb)176 .setup(dropDb)177 .setup(initDb)178 .setup(initCollection)179 .setup(createCollection)180 .beforeTask(dropCollection)181 .beforeTask(createCollection)182 .beforeTask(initCollection)183 .task(makeTestInsertOne(10))184 .teardown(dropDb)185 .teardown(disconnectClient)186 )187 )188 .suite('multiBench', suite =>189 suite190 .benchmark('findManyAndEmptyCursor', benchmark =>191 benchmark192 .taskSize(16.22)193 .setup(makeLoadJSON('tweet.json'))194 .setup(makeClient)195 .setup(connectClient)196 .setup(initDb)197 .setup(dropDb)198 .setup(initCollection)199 .setup(makeLoadTweets(false))200 .task(findManyAndEmptyCursor)201 .teardown(dropDb)202 .teardown(disconnectClient)203 )204 .benchmark('smallDocBulkInsert', benchmark =>205 benchmark206 .taskSize(2.75)207 .setup(makeLoadJSON('small_doc.json'))208 .setup(makeLoadInsertDocs(10000))209 .setup(makeClient)210 .setup(connectClient)211 .setup(initDb)212 .setup(dropDb)213 .setup(initDb)214 .setup(initCollection)215 .setup(createCollection)216 .beforeTask(dropCollection)217 .beforeTask(createCollection)218 .beforeTask(initCollection)219 .task(docBulkInsert)220 .teardown(dropDb)221 .teardown(disconnectClient)222 )223 .benchmark('largeDocBulkInsert', benchmark =>224 benchmark225 .taskSize(27.31)226 .setup(makeLoadJSON('large_doc.json'))227 .setup(makeLoadInsertDocs(10))228 .setup(makeClient)229 .setup(connectClient)230 .setup(initDb)231 .setup(dropDb)232 .setup(initDb)233 .setup(initCollection)234 .setup(createCollection)235 .beforeTask(dropCollection)236 .beforeTask(createCollection)237 .beforeTask(initCollection)238 .task(docBulkInsert)239 .teardown(dropDb)240 .teardown(disconnectClient)241 )242 .benchmark('gridFsUpload', benchmark =>243 benchmark244 .taskSize(52.43)245 .setup(loadGridFs)246 .setup(makeClient)247 .setup(connectClient)248 .setup(initDb)249 .setup(dropDb)250 .setup(initDb)251 .setup(initCollection)252 .beforeTask(dropBucket)253 .beforeTask(initBucket)254 .beforeTask(gridFsInitUploadStream)255 .beforeTask(writeSingleByteToUploadStream)256 .task(function (done) {257 this.stream.on('error', done).end(this.bin, null, () => done());258 })259 .teardown(dropDb)260 .teardown(disconnectClient)261 )262 .benchmark('gridFsDownload', benchmark =>263 benchmark264 .taskSize(52.43)265 .setup(loadGridFs)266 .setup(makeClient)267 .setup(connectClient)268 .setup(initDb)269 .setup(dropDb)270 .setup(initDb)271 .setup(initCollection)272 .setup(dropBucket)273 .setup(initBucket)274 .setup(gridFsInitUploadStream)275 .setup(function () {276 return new Promise((resolve, reject) => {277 this.stream.end(this.bin, null, err => {278 if (err) {279 return reject(err);280 }281 this.id = this.stream.id;282 this.stream = undefined;283 resolve();284 });285 });286 })287 .task(function (done) {288 this.bucket.openDownloadStream(this.id).resume().on('end', done);289 })290 .teardown(dropDb)291 .teardown(disconnectClient)292 )293 );294benchmarkRunner295 .run()296 .then(microBench => {297 const bsonBench = average(Object.values(microBench.bsonBench));298 const singleBench = average([299 microBench.singleBench.findOne,300 microBench.singleBench.smallDocInsertOne,301 microBench.singleBench.largeDocInsertOne302 ]);303 const multiBench = average(Object.values(microBench.multiBench));304 // TODO: add parallelBench305 const parallelBench = NaN;306 const readBench = average([307 microBench.singleBench.findOne,308 microBench.multiBench.findManyAndEmptyCursor,309 microBench.multiBench.gridFsDownload310 // TODO: Add parallelBench read benchmarks311 ]);312 const writeBench = average([313 microBench.singleBench.smallDocInsertOne,314 microBench.singleBench.largeDocInsertOne,315 microBench.multiBench.smallDocBulkInsert,316 microBench.multiBench.largeDocBulkInsert,317 microBench.multiBench.gridFsUpload318 // TODO: Add parallelBench write benchmarks319 ]);320 const driverBench = average([readBench, writeBench]);321 return {322 microBench,323 bsonBench,324 singleBench,325 multiBench,326 parallelBench,327 readBench,328 writeBench,329 driverBench330 };331 })332 .then(data => console.log(data))...

Full Screen

Full Screen

protocolLogin.ts

Source:protocolLogin.ts Github

copy

Full Screen

...28 constructor(arg: any) {29 super(arg);30 this.clientInfo = new LoginClientInfo();31 }32 public disconnectClient(text: string) {33 const output = new OutputMessage();34 const version = this.clientInfo.version;35 output.addByte(version >= 1076 ? 0x0B : 0x0A);36 output.addString(text);37 this.send(output);38 return this.disconnect();39 }40 public onRecvFirstMessage(msg: NetworkMessage): void {41 this.clientInfo.operatingSystem = msg.readUInt16();42 this.clientInfo.version = msg.readUInt16();43 this.clientInfo.protocolVersion = msg.readUInt32();44 this.clientInfo.datSignature = msg.readUInt32();45 this.clientInfo.sprSignature = msg.readUInt32();46 this.clientInfo.picSignature = msg.readUInt32();47 msg.skipBytes(1); // 0 byte idk what it is48 const beforeRSA = msg.getPosition();49 if (!this.decryptRSA(msg)) {50 return this.disconnect();51 }52 const key = new Uint32Array(4);53 key[0] = msg.readUInt32();54 key[1] = msg.readUInt32();55 key[2] = msg.readUInt32();56 key[3] = msg.readUInt32();57 const xtea: XTEA = new XTEA(key);58 this.enableXTEAEncryption(key);59 const connectionIP = this.connection.getIp();60 IPService.isBanned(connectionIP, (err) => {61 if (err) return this.disconnectClient(err);62 if (this.clientInfo.version < CLIENT_VERSION_MIN || this.clientInfo.version > CLIENT_VERSION_MAX) {63 return this.disconnectClient(`Only clients with protocol ${CLIENT_VERSION_STR} allowed!`);64 }65 if (g_game.getState() === GameState.Startup) {66 return this.disconnectClient("Gameworld is starting up. Please wait.");67 }68 if (g_game.getState() === GameState.Maintain) {69 return this.disconnectClient("Gameworld is under maintenance.\nPlease re-connect in a while.");70 }71 const accountName = msg.readString();72 if (accountName === "") {73 return this.disconnectClient("Invalid account name.");74 }75 const password = msg.readString();76 if (password === "") {77 return this.disconnectClient("Invalid password.");78 }79 msg.setPosition(beforeRSA + 128);80 msg.readUInt8(); // wtf is this?81 msg.readUInt8(); // wtf is this?82 this.clientInfo.hardware1 = msg.readString();83 this.clientInfo.hardware2 = msg.readString();84 let authToken = this.decryptRSA(msg) ? msg.readString() : "";85 this.processLogin(accountName, password, authToken);86 });87 }88 public parsePacket(msg: NetworkMessage): void { }89 private addWorldMotd(output: OutputMessage, motd?: string) {90 if (motd) {91 output.addByte(0x14);92 const motdNum = 1;93 output.addString(`${motdNum}\n ${motd}`);94 }95 }96 private addSessionKey(output: OutputMessage, sessionKey: string) {97 output.addByte(0x28);98 output.addString(sessionKey);99 }100 private addCharactersList(output: OutputMessage, worlds: any, characters: any) {101 output.addByte(0x64);102 output.addByte(worlds.length);103 for (let i = 0; i < worlds.length; i++) {104 const world = worlds[i];105 output.addByte(i); // world id106 output.addString(world.name);107 output.addString(world.ip);108 output.addUInt16(world.port);109 output.addByte(world.isPreview || 0);110 }111 const charactersLength = Math.min(characters.length, 20); // max 20 characters?112 output.addByte(charactersLength);113 for (let i = 0; i < charactersLength; i++) {114 const character = characters[i];115 output.addByte(character.worldId);116 output.addString(character.name);117 }118 }119 private addPremiumInfo(output: OutputMessage, premiumInfo: any) {120 output.addByte(0);121 if (g_config.game.freePremium) {122 output.addByte(1);123 output.addUInt32(0);124 } else {125 output.addByte(premiumInfo.isPremium);126 output.addUInt32(premiumInfo.timeStamp);127 }128 }129 private processLogin(accountName: string, password: string, authToken: string): void {130 AuthService.getCharactersList(accountName, password, authToken, (err, info) => {131 if (err) return this.disconnectClient(err);132 const ticks = new Date().getTime() / AUTHENTICATOR_PERIOD;133 const sessionKey = [accountName, password, authToken, ticks.toString()].join('\n');134 const output = new OutputMessage();135 this.addWorldMotd(output, g_config.game.motd);136 this.addSessionKey(output, sessionKey);137 this.addCharactersList(output, info.worlds, info.characters);138 this.addPremiumInfo(output, info.premium);139 this.send(output);140 return this.disconnect();141 });142 }...

Full Screen

Full Screen

network.js

Source:network.js Github

copy

Full Screen

...46 });47}48function onTimeout(client) {49 logger.log("warn", "Connection timeout: {0}:{1}".format(client.ip_address, client.port));50 disconnectClient(client);51 return;52}53function onData(client, data) {54 if (data !== null && data !== "") {55 // Data is bigger than 4096 bytes56 if (data.length > 4096) {57 disconnectClient(client);58 return;59 }60 try {61 logger.log("debug", "Recieved {0}:{1} > {2}".format(client.ip_address, client.port, prettyHex(data)), 'magenta');62 let buffer = Buffer.alloc(data.length);63 buffer.fill(data, 0, data.length, 'utf8');64 let array = Int32Array.from(buffer);65 // Handle splitting multiple Packet ID's on packets66 let index = 0;67 let size = buffer.length;68 while (index < size) {69 var len = (array[index + 1] | array[index + 2] << 8);70 if (array[index + 0] >= 0x80 && len > 0) {71 len += 7;72 }73 var final = array.slice(index, index+len);74 try {75 let packetId = final[index + 0];76 let packetLength = [final[index + 2] + final[index + 1]];77 let packetChecksum = [final[index + 3], final[index + 4], final[index + 5], final[index + 6]];78 let packetData = final.slice(7);79 //packets.decide(this, client, final);80 let packet = new EncryptedPacket(packetId, packetLength, packetChecksum, packetData);81 // TODO: Check if packet is valid, otherwise disconnect client82 // TODO: Decrypt packet83 // TODO: Depending on which mode is enabled process packet on that mode handler84 } catch (error) {85 logger.log("error", "Error processing packet: {0}".format(error));86 }87 index += len;88 }89 } catch (error) {90 logger.log("error", error);91 disconnectClient(client);92 return;93 }94 }95}96function onClose(client) {97 disconnectClient(client);98}99function onError(client, error) {100 logger.log("error", "Socket error {0}:{1} > {2}".format(client.ip_address, client.port, error));101 disconnectClient(client);102}103function sendData(client, data) {104 if (!client.socket.destroyed) {105 client.socket.write(data);106 logger.log("debug", "Sent {0}:{1} > {2}".format(data), 'magenta');107 }108}109function disconnectAll(callback) {110 if (clients.length == 0) {111 if (typeof(callback) == 'function') {112 return callback();113 }114 }115 for (var clientId in Object.keys(clients)) {116 let client = clients[clientId];117 if (client !== undefined) {118 disconnectClient(client);119 }120 }121 if (typeof(callback) == 'function') {122 return callback();123 }124}125function disconnectClient(client) {126 try {127 // If the client exists in the clients array128 if (clients.indexOf(client) >= 0) {129 // If this client has passed basic authentication130 if (client.clientState > 100) {131 // TODO: check if client is in active game/rooms132 // gracefully remove from those lists.133 logger.log("info", "Player {0} ({1}:{2}) disconnected".format(client.username, client.ip_address, client.port), "yellow");134 HTTPEvent.emit(global.config.api.url + "/player/disconnect", {135 username: client.username,136 ip_address: client.ip_address,137 port: client.port138 });139 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var http = require("best-http");2var client = new http.Client();3client.on("connect", function() {4 console.log("Connected");5 client.disconnectClient();6});7client.on("disconnect", function() {8 console.log("Disconnected");9});10var http = require("best-http");11var client = new http.Client();12client.on("connect", function() {13 console.log("Connected");14 client.disconnectClient();15});16client.on("disconnect", function() {17 console.log("Disconnected");18});19var http = require("best-http");20var client = new http.Client();21client.on("connect", function() {22 console.log("Connected");23 client.disconnectClient();24});25client.on("disconnect", function() {26 console.log("Disconnected");27});28var http = require("best-http");29var client = new http.Client();30client.on("connect", function() {31 console.log("Connected");32 client.disconnectClient();33});34client.on("disconnect", function() {35 console.log("Disconnected");36});37var http = require("best-http");38var client = new http.Client();39client.on("connect", function() {40 console.log("Connected");41 client.disconnectClient();42});43client.on("disconnect", function() {44 console.log("Disconnected");45});46var http = require("best-http");47var client = new http.Client();48client.on("connect", function() {49 console.log("Connected");50 client.disconnectClient();51});52client.on("disconnect", function() {53 console.log("Disconnected");54});

Full Screen

Using AI Code Generation

copy

Full Screen

1function disconnectClient() {2 var client = new HTTPClient();3 client.disconnectClient();4}5disconnectClient();6function destroyClient() {7 var client = new HTTPClient();8 client.destroyClient();9}10destroyClient();11function get() {12 var client = new HTTPClient();13}14get();15function post() {16 var client = new HTTPClient();17 var data = {18 }19}20post();21function put() {22 var client = new HTTPClient();23 var data = {24 }25}26put();27function del() {28 var client = new HTTPClient();29}30del();31function patch() {32 var client = new HTTPClient();33 var data = {34 }35}36patch();37function head() {38 var client = new HTTPClient();39}40head();41function options() {42 var client = new HTTPClient();43}44options();45function trace() {46 var client = new HTTPClient();47}48trace();49function connect() {50 var client = new HTTPClient();

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestHTTPSocketClient = require('./BestHTTPSocketClient.js');2var client = new BestHTTPSocketClient();3client.connect(url);4client.on('connect', function () {5 console.log("connected");6 client.disconnectClient();7 client.on('disconnect', function () {8 console.log("disconnected");9 });10});11var util = require('util');12var EventEmitter = require('events').EventEmitter;13function BestHTTPSocketClient() {14 EventEmitter.call(this);15 this._connected = false;16 this._socket = null;17 this._req = null;18 this._res = null;19 this._reqData = null;20 this._resData = null;21 this._headers = null;22 this._url = null;23 this._isConnecting = false;24 this._isDisconnecting = false;25 this._isConnected = false;26}27util.inherits(BestHTTPSocketClient, EventEmitter);28BestHTTPSocketClient.prototype.connect = function (url) {29 if (this._isConnecting || this._isDisconnecting || this._isConnected) {30 return;31 }32 this._isConnecting = true;33 this._url = url;34 this._req = require('http').request(url, this._onRequest.bind(this));35 this._req.on('error', this._onError.bind(this));36 this._req.on('close', this._onClose.bind(this));37 this._req.on('upgrade', this._onUpgrade.bind(this));38 this._req.end();39};40BestHTTPSocketClient.prototype.disconnectClient = function () {41 if (this._isConnecting || this._isDisconnecting || !this._isConnected) {42 return;43 }44 this._isDisconnecting = true;45 this._req.abort();46};47BestHTTPSocketClient.prototype._onRequest = function (res) {48 this._res = res;49 this._res.on('data', this._onResponseData.bind(this));50 this._res.on('end', this._onResponseEnd.bind(this));51};52BestHTTPSocketClient.prototype._onResponseData = function (data) {53 if (this._resData == null) {54 this._resData = data;55 } else {56 this._resData = Buffer.concat([this._resData, data]);57 }

Full Screen

Using AI Code Generation

copy

Full Screen

1importClass(Packages.com.bestv.ott.framework.net.BestHTTPClient);2var client = new BestHTTPClient();3client.disconnectClient();4importClass(Packages.com.bestv.ott.framework.net.BestHTTPClient);5var client = new BestHTTPClient();6client.setConnectTimeout(10000);7importClass(Packages.com.bestv.ott.framework.net.BestHTTPClient);8var client = new BestHTTPClient();9client.setReadTimeout(10000);10importClass(Packages.com.bestv.ott.framework.net.BestHTTPClient);11var client = new BestHTTPClient();12client.setRequestProperty("Content-Type","application/json");13importClass(Packages.com.bestv.ott.framework.net.BestHTTPClient);14var client = new BestHTTPClient();15client.setRequestMethod("POST");16importClass(Packages.com.bestv.ott.framework.net.BestHTTPClient);17var client = new BestHTTPClient();18client.setRequestProperty("Content-Type","application/json");19importClass(Packages.com.bestv.ott.framework.net.BestHTTPClient);20var client = new BestHTTPClient();21client.connect();22var responseCode = client.getResponseCode();23client.disconnectClient();24importClass(Packages.com.bestv.ott.framework.net.BestHTTPClient);25var client = new BestHTTPClient();26client.connect();27var responseMessage = client.getResponseMessage();28client.disconnectClient();29importClass(Packages.com.bestv.ott.framework.net.BestHTTPClient);30var client = new BestHTTPClient();31client.connect();32var headerField = client.getHeaderField("Content-Type");33client.disconnectClient();

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestHTTP:SocketIO.SocketIOComponent;2function Start () {3 BestHTTP.SocketIO.SocketIOComponent = new GameObject("SocketIO").AddComponent(BestHTTP.SocketIO.SocketIOComponent);4}5function OnGUI () {6 if (BestHTTP.SocketIO.SocketIOComponent.IsConnected) {7 if (GUI.Button(Rect(10, 10, 100, 30), "Disconnect")) {8 BestHTTP.SocketIO.SocketIOComponent.Disconnect();9 }10 }11}12var BestHTTP:SocketIO.SocketIOComponent;13function Start () {14 BestHTTP.SocketIO.SocketIOComponent = new GameObject("SocketIO").AddComponent(BestHTTP.SocketIO.SocketIOComponent);15}16function OnGUI () {17 if (BestHTTP.SocketIO.SocketIOComponent.IsConnected) {18 if (GUI.Button(Rect(10, 10, 100, 30), "Disconnect")) {19 BestHTTP.SocketIO.SocketIOComponent.Disconnect();20 }21 }22}23var BestHTTP:SocketIO.SocketIOComponent;24function Start () {25 BestHTTP.SocketIO.SocketIOComponent = new GameObject("SocketIO").AddComponent(BestHTTP.SocketIO.SocketIOComponent);26}27function OnGUI () {28 if (BestHTTP.SocketIO.SocketIOComponent.IsConnected) {29 if (GUI.Button(Rect(10, 10, 100, 30), "Disconnect"))

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestHTTPClient = require('BestHTTPClient');2var client = new BestHTTPClient();3var path = '/disconnect';4var params = {clientUrl: clientUrl};5client.post(serverUrl, path, params, function (err, data) {6 if (err) {7 console.error('error:', err);8 } else {9 console.log('data:', data);10 }11});

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestHTTP = require('best-http');2var http = new BestHTTP();3var request = http.get(url);4var response = request.send();5http.disconnectClient();6var request2 = http.get(url);7var response2 = request2.send();8if(response2.statusCode == 200) {9 console.log('The request was successful');10} else {11 console.log('The request failed');12}

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Best automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful