Skip to content

Commit cc570c7

Browse files
committed
Client initilization
1 parent fa25e81 commit cc570c7

File tree

2 files changed

+35
-46
lines changed

2 files changed

+35
-46
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"devDependencies": {
3333
"@types/mocha": "^2.2.42",
3434
"@types/node": "^10.12.21",
35-
"@types/pusher-js": "^4.2.2",
3635
"awesome-typescript-loader": "^5.2.1",
3736
"source-map-loader": "^0.2.4",
3837
"tslint": "^5.12.1",

src/extension.ts

Lines changed: 35 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import * as vscode from 'vscode';
1010
// import { web_rtc } from "electron-webrtc-patched";
1111

1212

13-
import * as tc from '@atom/teletype-client';
13+
// import * as tc from '@atom/teletype-client';
14+
// import GuestPortalBinding from './GuestPortalBinding';
1415

15-
// const TeletypeClient= require('@atom/teletype-client');
16+
import { TeletypeClient } from '@atom/teletype-client';
1617
// const teletype = require('teletype')
1718

1819

@@ -46,68 +47,57 @@ async function joinPortal(portalId: any) {
4647
return;
4748
}
4849

49-
// const params = {databaseURL: process.env.TEST_DATABASE_URL};
50-
// // Uncomment and provide credentials to test against Pusher.
51-
// params.pusherCredentials = {
52-
// appId: '123',
53-
// key: '123',
54-
// secret: '123'
55-
// };
56-
// let server = await startTestServer(params);
50+
try {
51+
const stubRestGateway = {
52+
setOauthToken() { },
53+
get() {
54+
return Promise.resolve({ ok: true, body: [] });
55+
}
56+
};
57+
const stubPubSubGateway = {
58+
subscribe() {
59+
return Promise.resolve({
60+
dispose() { }
61+
});
62+
}
63+
};
5764

5865

59-
try {
60-
let client = new tc.TeletypeClient(
61-
{
62-
restGateway: {}
63-
},
64-
{
65-
pubSubGateway: {}
66-
},
67-
{
68-
connectionTimeout: 5000
69-
},
70-
{
71-
tetherDisconnectWindow: 100
66+
const client = new TeletypeClient({
67+
restGateway: stubPubSubGateway,
68+
pubSubGateway: stubRestGateway,
69+
connectionTimeout: 5000,
70+
tetherDisconnectWindow: 100,
71+
testEpoch: {},
72+
pusherKey: 'b89ba30a0bbb1fb2e283',
73+
pusherOptions: {
74+
cluster: 'ap2'
7275
},
73-
{
74-
testEpoch: {}
75-
},
76-
{
77-
pusherKey: 'f119821248b7429bece3'
78-
},
79-
{
80-
pusherOptions: {
81-
cluster: 'mt1'
82-
}
83-
},
84-
{
85-
baseURL: 'https://api.teletype.atom.io'
86-
},
87-
{
88-
didCreateOrJoinPortal: {}
89-
});
76+
baseURL: 'https://api.teletype.atom.io',
77+
didCreateOrJoinPortal: true,
78+
});
9079

91-
client.onConnectionError = (event: any) => {
92-
throw (newFunction("${event.message}"));
80+
// client.onConnectionError((error) => errorEvents.push(error))
81+
client.onConnectionError = (event) => {
82+
throw new Error((`Connection Error: An error occurred with a teletype connection: ${event.message}`));
9383
};
9484
await client.initialize();
9585

96-
await client.signIn(process.env.AUTH_TOKEN);
86+
// await client.signIn(process.env.AUTH_TOKEN);
9787

9888
// const portalBinding = new GuestPortalBinding({
9989
// portalId,
10090
// client,
10191
// editor: vscode.window.activeTextEditor
10292
// });
103-
// await portalBinding.initialize();
104-
93+
// await portalBinding.initialize()
10594

10695
} catch (e) {
10796
console.log("Error in creating teletype client " + e);
10897
}
10998

11099

100+
111101
vscode.window.showInformationMessage('Joining Portal with ID' + ' ' + portalId + ' ');
112102

113103

0 commit comments

Comments
 (0)