From 7a45de24bdac0d8b524da14cc2346dc02e65017f Mon Sep 17 00:00:00 2001 From: "dominic.griesel" Date: Mon, 18 Dec 2017 12:02:18 +0100 Subject: [PATCH] removed a bunch of unused code --- build/CoapClient.d.ts | 2 -- build/CoapClient.js | 11 ++--------- src/CoapClient.ts | 11 ++--------- src/Message.ts | 1 - 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/build/CoapClient.d.ts b/build/CoapClient.d.ts index 8d5bab5d..4b1c3d03 100644 --- a/build/CoapClient.d.ts +++ b/build/CoapClient.d.ts @@ -40,8 +40,6 @@ export declare class CoapClient { private static pendingRequestsByUrl; /** Queue of the messages waiting to be sent */ private static sendQueue; - /** Number of message we expect an answer for */ - private static concurrency; /** * Sets the security params to be used for the given hostname */ diff --git a/build/CoapClient.js b/build/CoapClient.js index ce4a97e7..a03e0325 100644 --- a/build/CoapClient.js +++ b/build/CoapClient.js @@ -184,14 +184,12 @@ class CoapClient { options.retransmit = true; // retrieve or create the connection we're going to use const origin = Origin_1.Origin.fromUrl(url); - const originString = origin.toString(); const connection = yield CoapClient.getConnection(origin); // find all the message parameters const type = options.confirmable ? Message_1.MessageType.CON : Message_1.MessageType.NON; const code = Message_1.MessageCodes.request[method]; const messageId = connection.lastMsgId = incrementMessageID(connection.lastMsgId); const token = connection.lastToken = incrementToken(connection.lastToken); - const tokenString = token.toString("hex"); payload = payload || Buffer.from([]); // create message options, be careful to order them by code, no sorting is implemented yet const msgOptions = []; @@ -368,14 +366,12 @@ class CoapClient { options.retransmit = true; // retrieve or create the connection we're going to use const origin = Origin_1.Origin.fromUrl(url); - const originString = origin.toString(); const connection = yield CoapClient.getConnection(origin); // find all the message parameters const type = options.confirmable ? Message_1.MessageType.CON : Message_1.MessageType.NON; const code = Message_1.MessageCodes.request[method]; const messageId = connection.lastMsgId = incrementMessageID(connection.lastMsgId); const token = connection.lastToken = incrementToken(connection.lastToken); - const tokenString = token.toString("hex"); payload = payload || Buffer.from([]); // create message options, be careful to order them by code, no sorting is implemented yet const msgOptions = []; @@ -393,8 +389,8 @@ class CoapClient { msgOptions.push(...pathParts.map(part => Option_1.Options.UriPath(part))); // [12] content format msgOptions.push(Option_1.Options.ContentFormat(ContentFormats_1.ContentFormats.application_json)); - // create the promise we're going to return - const response = DeferredPromise_1.createDeferredPromise(); + // In contrast to requests, we don't work with a deferred promise when observing + // Instead, we invoke a callback for *every* response. // create the message we're going to send const message = CoapClient.createMessage(type, code, messageId, token, msgOptions, payload); // create the retransmission info @@ -733,7 +729,6 @@ class CoapClient { target = Origin_1.Origin.fromUrl(target); } // retrieve or create the connection we're going to use - const originString = target.toString(); try { yield CoapClient.getConnection(target); return true; @@ -876,6 +871,4 @@ CoapClient.pendingRequestsByMsgID = {}; CoapClient.pendingRequestsByUrl = {}; /** Queue of the messages waiting to be sent */ CoapClient.sendQueue = []; -/** Number of message we expect an answer for */ -CoapClient.concurrency = 0; exports.CoapClient = CoapClient; diff --git a/src/CoapClient.ts b/src/CoapClient.ts index 7b9f5735..3e5d4695 100644 --- a/src/CoapClient.ts +++ b/src/CoapClient.ts @@ -179,8 +179,6 @@ export class CoapClient { private static pendingRequestsByUrl: { [url: string]: PendingRequest } = {}; /** Queue of the messages waiting to be sent */ private static sendQueue: QueuedMessage[] = []; - /** Number of message we expect an answer for */ - private static concurrency: number = 0; /** * Sets the security params to be used for the given hostname @@ -273,7 +271,6 @@ export class CoapClient { // retrieve or create the connection we're going to use const origin = Origin.fromUrl(url); - const originString = origin.toString(); const connection = await CoapClient.getConnection(origin); // find all the message parameters @@ -281,7 +278,6 @@ export class CoapClient { const code = MessageCodes.request[method]; const messageId = connection.lastMsgId = incrementMessageID(connection.lastMsgId); const token = connection.lastToken = incrementToken(connection.lastToken); - const tokenString = token.toString("hex"); payload = payload || Buffer.from([]); // create message options, be careful to order them by code, no sorting is implemented yet @@ -482,7 +478,6 @@ export class CoapClient { // retrieve or create the connection we're going to use const origin = Origin.fromUrl(url); - const originString = origin.toString(); const connection = await CoapClient.getConnection(origin); // find all the message parameters @@ -490,7 +485,6 @@ export class CoapClient { const code = MessageCodes.request[method]; const messageId = connection.lastMsgId = incrementMessageID(connection.lastMsgId); const token = connection.lastToken = incrementToken(connection.lastToken); - const tokenString = token.toString("hex"); payload = payload || Buffer.from([]); // create message options, be careful to order them by code, no sorting is implemented yet @@ -508,8 +502,8 @@ export class CoapClient { // [12] content format msgOptions.push(Options.ContentFormat(ContentFormats.application_json)); - // create the promise we're going to return - const response = createDeferredPromise(); + // In contrast to requests, we don't work with a deferred promise when observing + // Instead, we invoke a callback for *every* response. // create the message we're going to send const message = CoapClient.createMessage(type, code, messageId, token, msgOptions, payload); @@ -929,7 +923,6 @@ export class CoapClient { } // retrieve or create the connection we're going to use - const originString = target.toString(); try { await CoapClient.getConnection(target); return true; diff --git a/src/Message.ts b/src/Message.ts index 53eb75a0..88c9e592 100644 --- a/src/Message.ts +++ b/src/Message.ts @@ -1,5 +1,4 @@ import { Option } from "./Option"; -import { fail } from "assert"; export enum MessageType { CON = 0, // Confirmable