-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lock notification #7026
base: master
Are you sure you want to change the base?
Lock notification #7026
Conversation
class WebSocketService { | ||
constructor(onMessageCallback, repoId) { | ||
|
||
this.url = 'ws://localhost:8083'; // WebSocket address; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url不要在这里写死, 写到seahub_settings里面然后,通过html中继器来读取
@@ -146,8 +146,40 @@ class LibContentView extends React.Component { | |||
componentDidMount() { | |||
this.unsubscribeEvent = this.props.eventBus.subscribe(EVENT_BUS_TYPE.SEARCH_LIBRARY_CONTENT, this.onSearchedClick); | |||
this.calculatePara(this.props); | |||
this.socket = new WebSocketService(this.onMessageCallback, this.props.repoID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个写在constructor的构造方法下面
@@ -0,0 +1,101 @@ | |||
import { userAPI } from '../utils/user-api'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
文件名改成 listen-notification --> websocket-service.js
|
||
handleMessage(data) { | ||
switch (data.type) { | ||
case 'file-lock-changed': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不需要用case的吧, 在回调处进行判断就可以了。 websocke-service层面这里不需要知道具体的数据类型(尽量与seafile中的业务数据分离)。 接受到消息,把数据传递给回调函数, 然后在调用函数的外部组件中去扩展就可以了
} | ||
|
||
close() { | ||
this.shouldReconnect = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里需要发送请求来unsubscribe这个repo
this.url = 'ws://localhost:8083'; // WebSocket address; | ||
this.repoId = repoId; | ||
this.socket = null; | ||
this.heartbeatInterval = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里heartbetInterval好像没用到, 看看是不是可以删掉
2b07e94
to
c671f8a
Compare
63acdd5
to
a276945
Compare
a276945
to
e185985
Compare
No description provided.