Skip to content

Instantly share code, notes, and snippets.

render() {
const { chatLog, options } = this.state;
return (
<div className="App">
<LioWebRTC
options={options}
onReady={this.join}
onCreatedPeer={this.handleCreatedPeer}
onReceivedPeerData={this.handlePeerData}
>
import React, { Component } from 'react';
import './App.css';
import ChatBox from './ChatBox';
class App extends Component {
constructor(props) {
super(props);
this.state = {
chatLog: []
}
.container {
width: 500px;
max-width: 100%;
display: flex;
flex-flow: column;
margin: 10px auto;
border-radius: 5px;
padding: 0;
background-color: #383838;
border: 1px solid #333;
import React, { Component } from 'react';
import './ChatBox.css';
class ChatBox extends Component {
constructor(props) {
super(props);
this.state = {
inputMsg: ''
};
}
@lazorfuzz
lazorfuzz / App.js
Last active December 13, 2018 13:15
import React, { Component } from 'react';
import './App.css';
import ChatBox from './ChatBox';
class App extends Component {
render() {
return (
<div className="App">
<ChatBox />
</div>
import React, { Component } from 'react';
class ChatBox extends Component {
render() {
return (
<div>
<p>Hello world!</p>
</div>
);
}
join = (webrtc) => webrtc.joinRoom('my-p2p-app-demo');
handleCreatedPeer = (webrtc, peer) => {
this.addChat(`Peer-${peer.id.substring(0, 5)} joined the room!`, ' ', true);
}
handlePeerData = (webrtc, type, payload, peer) => {
switch(type) {
case 'chat':
this.addChat(`Peer-${peer.id.substring(0, 5)}`, payload);
@lazorfuzz
lazorfuzz / App.js
Last active December 13, 2018 13:27
import React, { Component } from 'react';
import { LioWebRTC } from 'react-liowebrtc';
import './App.css';
import ChatBox from './ChatBox';
class App extends Component {
constructor(props) {
super(props);
this.state = {
chatLog: [],
handleSend = (chatMsg) => {
this.props.webrtc.shout('chat', chatMsg);
this.props.onSend(chatMsg);
}
@lazorfuzz
lazorfuzz / demo.js
Created August 16, 2019 08:25
Fail.js
const vm = require('vm');
console.log(vm.runInNewContext('this.constructor.constructor("return process")().env'));