Skip to content

Commit

Permalink
removed a bunch of unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Dec 18, 2017
1 parent 662005b commit 7a45de2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 21 deletions.
2 changes: 0 additions & 2 deletions build/CoapClient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
11 changes: 2 additions & 9 deletions build/CoapClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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 = [];
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
11 changes: 2 additions & 9 deletions src/CoapClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -273,15 +271,13 @@ 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
const type = options.confirmable ? MessageType.CON : MessageType.NON;
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
Expand Down Expand Up @@ -482,15 +478,13 @@ 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
const type = options.confirmable ? MessageType.CON : MessageType.NON;
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
Expand All @@ -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<CoapResponse>();
// 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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/Message.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Option } from "./Option";
import { fail } from "assert";

export enum MessageType {
CON = 0, // Confirmable
Expand Down

0 comments on commit 7a45de2

Please sign in to comment.