Moved session and connection helpers and change data sending to use write streams
This commit is contained in:
parent
01e006f5e6
commit
37542dc0e6
@ -2,7 +2,7 @@ import SimplePeer from "simple-peer";
|
|||||||
import { encode, decode } from "@msgpack/msgpack";
|
import { encode, decode } from "@msgpack/msgpack";
|
||||||
import shortid from "shortid";
|
import shortid from "shortid";
|
||||||
|
|
||||||
import blobToBuffer from "./blobToBuffer";
|
import blobToBuffer from "../helpers/blobToBuffer";
|
||||||
|
|
||||||
// Limit buffer size to 16kb to avoid issues with chrome packet size
|
// Limit buffer size to 16kb to avoid issues with chrome packet size
|
||||||
// http://viblast.com/blog/2015/2/5/webrtc-data-channel-message-size/
|
// http://viblast.com/blog/2015/2/5/webrtc-data-channel-message-size/
|
||||||
@ -63,7 +63,8 @@ class Connection extends SimplePeer {
|
|||||||
const chunks = this.chunk(packedData);
|
const chunks = this.chunk(packedData);
|
||||||
for (let chunk of chunks) {
|
for (let chunk of chunks) {
|
||||||
if (this.dataChannels[channel]) {
|
if (this.dataChannels[channel]) {
|
||||||
this.dataChannels[channel].send(encode(chunk));
|
// Write to the stream to allow for buffer / backpressure handling
|
||||||
|
this.dataChannels[channel].write(encode(chunk));
|
||||||
} else {
|
} else {
|
||||||
super.send(encode(chunk));
|
super.send(encode(chunk));
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ import { omit } from "../helpers/shared";
|
|||||||
import useDebounce from "../helpers/useDebounce";
|
import useDebounce from "../helpers/useDebounce";
|
||||||
// Load session for auto complete
|
// Load session for auto complete
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
import Session from "../helpers/Session";
|
import Session from "./Session";
|
||||||
|
|
||||||
import Map from "../components/map/Map";
|
import Map from "../components/map/Map";
|
||||||
import Tokens from "../components/token/Tokens";
|
import Tokens from "../components/token/Tokens";
|
||||||
|
@ -2,7 +2,7 @@ import React, { useContext, useState, useEffect, useCallback } from "react";
|
|||||||
|
|
||||||
// Load session for auto complete
|
// Load session for auto complete
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
import Session from "../helpers/Session";
|
import Session from "./Session";
|
||||||
import { isStreamStopped, omit, fromEntries } from "../helpers/shared";
|
import { isStreamStopped, omit, fromEntries } from "../helpers/shared";
|
||||||
|
|
||||||
import AuthContext from "../contexts/AuthContext";
|
import AuthContext from "../contexts/AuthContext";
|
||||||
|
@ -3,7 +3,7 @@ import { EventEmitter } from "events";
|
|||||||
|
|
||||||
import Connection from "./Connection";
|
import Connection from "./Connection";
|
||||||
|
|
||||||
import { omit } from "./shared";
|
import { omit } from "../helpers/shared";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {object} SessionPeer
|
* @typedef {object} SessionPeer
|
@ -14,7 +14,7 @@ import { MapStageProvider } from "../contexts/MapStageContext";
|
|||||||
import NetworkedMapAndTokens from "../network/NetworkedMapAndTokens";
|
import NetworkedMapAndTokens from "../network/NetworkedMapAndTokens";
|
||||||
import NetworkedParty from "../network/NetworkedParty";
|
import NetworkedParty from "../network/NetworkedParty";
|
||||||
|
|
||||||
import Session from "../helpers/Session";
|
import Session from "../network/Session";
|
||||||
|
|
||||||
const session = new Session();
|
const session = new Session();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user