generated from Alissonsz/next-bulma-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,393 additions
and
2,113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import axios from 'axios'; | ||
|
||
const SERVER_URL = | ||
process.env.NEXT_PUBLIC_SERVER_URL || 'http://localhost:8080'; | ||
const url = | ||
process.env.NODE_ENV === 'production' | ||
? 'https://jun2-ish.fun' | ||
: 'http://localhost:8080'; | ||
const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL || url; | ||
|
||
const api = axios.create({ | ||
baseURL: SERVER_URL, | ||
headers: { | ||
'Access-Control-Allow-Origin': '*', | ||
}, | ||
}); | ||
|
||
export default api; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { IChatMessage, IPlaylistItem } from '../stores/roomSlice'; | ||
|
||
const url = | ||
process.env.NODE_ENV === 'production' | ||
? 'wss://jun2-ish.fun/ws' | ||
: 'ws://localhost:8080/ws'; | ||
|
||
const socket = { | ||
conn: new WebSocket(url), | ||
emit: (type: string, data: any) => { | ||
if (socket.conn.readyState !== WebSocket.OPEN) return; | ||
|
||
socket.conn.send(JSON.stringify({ type, data })); | ||
}, | ||
on: (type: string, callback: (data: any) => void) => { | ||
socket.conn.addEventListener('message', (event) => { | ||
const { type: eventType, data } = JSON.parse(event.data); | ||
console.log({ type, data }); | ||
|
||
if (type === eventType) { | ||
callback(data); | ||
} | ||
}); | ||
}, | ||
}; | ||
|
||
socket.conn.onopen = () => { | ||
console.log('connected!'); | ||
}; | ||
|
||
socket.conn.onmessage = (message) => { | ||
console.log(message); | ||
}; | ||
|
||
socket.conn.onerror = (error) => { | ||
console.log(error); | ||
}; | ||
|
||
export const sendNewMessage = (roomId: string, message: IChatMessage) => { | ||
socket.emit('newMessage', message); | ||
}; | ||
|
||
export const sendEntryRoom = (roomId: string, nickname: string) => { | ||
const payload = { | ||
roomId, | ||
nickname, | ||
}; | ||
|
||
socket.emit('joinRoom', payload); | ||
}; | ||
|
||
export const sendVideoChange = (roomId: string, videoUrl: string) => { | ||
const payload = { | ||
roomId, | ||
videoUrl, | ||
}; | ||
|
||
socket.emit('changeVideo', payload); | ||
}; | ||
|
||
export const sendVideoPlayingChange = ( | ||
roomId: string, | ||
progress: number, | ||
playing: boolean | ||
) => { | ||
const payload = { progress, playing }; | ||
|
||
socket.emit('videoPlayingChanged', payload); | ||
}; | ||
|
||
export const sendVideoSeek = (roomId: string, seekTo: number) => { | ||
const payload = { roomId, seekTo }; | ||
socket.emit('videoSeeked', payload); | ||
}; | ||
|
||
export const sendPlayingProgress = (roomId: string, progress) => { | ||
const payload = { roomId, progress }; | ||
socket.emit('playingProgress', payload); | ||
}; | ||
|
||
export const sendVideoAddedToPlaylist = ( | ||
roomId: string, | ||
video: IPlaylistItem | ||
) => { | ||
const payload = { ...video }; | ||
socket.emit('addVideoToPlaylist', payload); | ||
}; | ||
|
||
export const sendReorderPlaylist = (roomId: string, list: IPlaylistItem[]) => { | ||
const payload = { roomId, list }; | ||
socket.emit('updatePlaylist', payload); | ||
}; | ||
|
||
export const sendPlayNext = (roomId: string) => { | ||
socket.emit('playNext', { roomId }); | ||
}; | ||
|
||
export default socket; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
@charset "utf-8"; | ||
|
||
// Set your brand colors | ||
@import "base.scss"; | ||
@import "base.scss" | ||
|
||
// Import only what you need from Bulma | ||
@import "~bulma/bulma"; | ||
@import "~bulma-slider"; | ||
@import "~bulma-tooltip"; | ||
@import "~bulma/bulma" | ||
@import "~bulma-slider" | ||
@import "~bulma-tooltip" | ||
// @import "../node_modules/bulma/bulma.sass" |
Oops, something went wrong.
18f596f
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.
Successfully deployed to the following URLs:
jun2-ish – ./
jun2-ish-git-adapting-goapi-alissonsz.vercel.app
jun2-ish-alissonsz.vercel.app
jun2-ish.vercel.app