Skip to content
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

vue中调用LiveTCP出错 #25

Closed
dfaofeng opened this issue May 29, 2020 · 1 comment
Closed

vue中调用LiveTCP出错 #25

dfaofeng opened this issue May 29, 2020 · 1 comment

Comments

@dfaofeng
Copy link

dfaofeng commented May 29, 2020

QQ截图20200530010021
image

<script> document.title = 'BiliBili直播弹幕抽奖' // import connect from "./websocketClient/BiliLiveWs"; import RoomChoosing from "./components/RoomChoosing"; import Recording from "./components/Recording"; import Lottery from "./components/Lottery"; import Result from "./components/Result"; import {LiveTCP} from "bilibili-live-ws"; export default { name: 'App', components: { Result, Lottery, Recording, RoomChoosing }, data: () => ({ currentStep: 1, roomid: 0, recording: false, involvedUid: [], // 所有参与用户的uid involvedUname: {}, // 所有参与用户的用户名 luckyDogs: [] }), methods: { enterRoom: function(rid) { this.involvedUid = []; this.involvedUname = {}; this.recording = true; this.roomid = parseInt(rid); this.connectWs(); this.currentStep++; }, stopRecording: function() { this.recording = false; this.currentStep++; }, onDanmu: function(userInfo) { if (this.recording && !this.involvedUid.includes(userInfo[2][0])) { this.involvedUid.push(userInfo[2][0].toString()); this.involvedUname[userInfo[2][0]] = userInfo[2][1]; } }, connectWs: function() { console.log(this.roomid) let live = new LiveTCP(this.roomid); live.on('open'); live.on('live', () => { live.on('heartbeat') live.on('DANMU_MSG', (data) => { this.onDanmu(data.info) }) }) } } } </script>
@simon300000
Copy link
Owner

simon300000 commented May 30, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants