Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
foreign
/
customer-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bfddd649
authored
Nov 19, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
cs
parent
fdd3ea77
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
5 deletions
model/index.ts
xim/index.ts
model/index.ts
View file @
bfddd649
...
@@ -44,13 +44,25 @@ export const enum ServiceType {
...
@@ -44,13 +44,25 @@ export const enum ServiceType {
Backend
,
Backend
,
}
}
export
const
enum
ImEnvironment
{
Dev
=
1
,
Stage
,
Pro
}
export
const
socketMapping
=
new
Map
<
ImEnvironment
,
string
>
([
[
ImEnvironment
.
Dev
,
'ws://hro.channel.jinsehuaqin.com:8080/ws'
],
[
ImEnvironment
.
Stage
,
''
],
[
ImEnvironment
.
Pro
,
'wss://channel.qinqinxiaobao.com/ws'
],
]);
export
type
TokenStringGetter
=
()
=>
Promise
<
string
>
;
export
type
TokenStringGetter
=
()
=>
Promise
<
string
>
;
export
interface
ChatOption
{
export
interface
ChatOption
{
/**
/**
*
长链接chat sdk
地址
*
IM 链接,如果使用系统配置,只需要传入环境标识即可,如果默认配置不满足,可以传入指定
地址
*/
*/
webSocketUri
:
string
;
connection
:
ImEnvironment
|
string
;
sdk
:
()
=>
UniplatSdk
;
sdk
:
()
=>
UniplatSdk
;
...
...
xim/index.ts
View file @
bfddd649
...
@@ -8,6 +8,8 @@ import {
...
@@ -8,6 +8,8 @@ import {
ServiceType
,
ServiceType
,
CustomerServiceProduct
,
CustomerServiceProduct
,
ChatMessageController
,
ChatMessageController
,
socketMapping
,
ImEnvironment
,
}
from
"./../model"
;
}
from
"./../model"
;
import
{
ChatLoggerService
}
from
"./logger"
;
import
{
ChatLoggerService
}
from
"./logger"
;
import
tokenManager
from
"./token"
;
import
tokenManager
from
"./token"
;
...
@@ -41,7 +43,7 @@ class Chat implements ChatMessageController {
...
@@ -41,7 +43,7 @@ class Chat implements ChatMessageController {
throw
new
Error
(
`You must specify a chat option for chat service`
);
throw
new
Error
(
`You must specify a chat option for chat service`
);
}
}
if
(
!
option
.
webSocketUri
)
{
if
(
!
option
.
connection
)
{
throw
new
Error
(
throw
new
Error
(
`You must specify a web socket address for chat service`
`You must specify a web socket address for chat service`
);
);
...
@@ -71,7 +73,9 @@ class Chat implements ChatMessageController {
...
@@ -71,7 +73,9 @@ class Chat implements ChatMessageController {
// this.keywords = ["社保"];
// this.keywords = ["社保"];
return
this
.
initChatSdk
((
this
.
ws
=
option
.
webSocketUri
)).
finally
(()
=>
{
const
path
=
socketMapping
.
get
(
option
.
connection
as
ImEnvironment
)
as
string
||
option
.
connection
as
string
;
return
this
.
initChatSdk
((
this
.
ws
=
path
)).
finally
(()
=>
{
this
.
connected
=
true
;
this
.
connected
=
true
;
for
(
const
item
of
this
.
connectedActions
)
{
for
(
const
item
of
this
.
connectedActions
)
{
item
();
item
();
...
@@ -193,7 +197,7 @@ class Chat implements ChatMessageController {
...
@@ -193,7 +197,7 @@ class Chat implements ChatMessageController {
this
.
messageController
&&
this
.
messageController
.
info
(
msg
);
this
.
messageController
&&
this
.
messageController
.
info
(
msg
);
}
}
public
getAvatar
(){
public
getAvatar
()
{
return
this
.
defaultAvatar
;
return
this
.
defaultAvatar
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment