castle-chat-lib
Advanced tools
Comparing version 1.3.0 to 1.4.0
{ | ||
"name": "castle-chat-lib", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "", | ||
@@ -13,2 +13,3 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"castle-api-client": "^6.0.0", | ||
"jquery": "^3.3.1", | ||
@@ -15,0 +16,0 @@ "lodash": "^4.17.11", |
@@ -5,3 +5,6 @@ import Candy from './candy/candy'; | ||
import _ from 'lodash'; | ||
import CastleApiClient from 'castle-api-client'; | ||
export const API = CastleApiClient('https://api.castle.games'); | ||
const PRESENCE_DEBOUNCE_DELAY = 100; | ||
@@ -75,2 +78,6 @@ const PRESENCE_DEBOUNCE_MAX_WAIT = 500; | ||
async _debugSetTokenInStorageAsync() { | ||
await API.client.setTokenAsync(this._token); | ||
} | ||
connect() { | ||
@@ -129,6 +136,3 @@ if (this._chat) { | ||
this._chat.Core.connect( | ||
`${this._userId}@castle.games`, | ||
this._token | ||
); | ||
this._chat.Core.connect(`${this._userId}@castle.games`, this._token); | ||
} | ||
@@ -187,11 +191,19 @@ | ||
sendMessage(channel, message) { | ||
async sendMessageAsync(channel, message) { | ||
try { | ||
this._chat.Core.Action.Jabber.Room.Message( | ||
`${channel}@conference.castle.games`, | ||
message, | ||
'groupchat', | ||
null, | ||
uuidv4() | ||
let result = await API.graphqlAsync( | ||
` | ||
mutation($roomName: String!, $message: String!) { | ||
sendChatMessage(roomName: $roomName, message: $message) | ||
} | ||
`, | ||
{ | ||
roomName: channel, | ||
message, | ||
} | ||
); | ||
if (result.errors && result.errors.length) { | ||
throw new Error(result.errors); | ||
} | ||
} catch (e) { | ||
@@ -198,0 +210,0 @@ console.log('send message error'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
125612
3851
9
+ Addedcastle-api-client@^6.0.0
+ Addedapollo-fetch@0.7.0(transitive)
+ Addedcastle-api-client@6.1.0(transitive)
+ Addedcross-fetch@1.1.1(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedextract-files@4.1.0(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addednode-fetch@1.7.3(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedwhatwg-fetch@2.0.3(transitive)