forked from libp2p/universal-connectivity
-
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.
feat: add naive request-response for js (libp2p#6)
- Loading branch information
1 parent
6a4eec4
commit 6e2598f
Showing
7 changed files
with
174 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React, { createContext, useContext, useState } from 'react'; | ||
|
||
export interface ChatFile { | ||
id: string | ||
body: Uint8Array | ||
provider: string | ||
} | ||
|
||
export interface FileChatContextInterface { | ||
files: Map<string, ChatFile> | ||
setFiles: (files: Map<string, ChatFile>) => void; | ||
} | ||
export const fileContext = createContext<FileChatContextInterface>({ | ||
files: new Map<string, ChatFile>(), | ||
setFiles: () => { } | ||
}) | ||
|
||
export const useFileChatContext = () => { | ||
return useContext(fileContext); | ||
}; | ||
|
||
export const FileProvider = ({ children }: any) => { | ||
const [files, setFiles] = useState<Map<string, ChatFile>>(new Map<string, ChatFile>()); | ||
|
||
return ( | ||
<fileContext.Provider value={{ files, setFiles }}> | ||
{children} | ||
</fileContext.Provider> | ||
); | ||
}; | ||
|
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,6 +1,8 @@ | ||
export const CHAT_TOPIC = "universal-connectivity" | ||
export const CHAT_FILE_TOPIC = "universal-connectivity-file" | ||
export const FILE_EXCHANGE_PROTOCOL = "/universal-connectivity-file/1" | ||
|
||
export const CIRCUIT_RELAY_CODE = 290 | ||
|
||
export const WEBRTC_BOOTSTRAP_NODE = "/ip4/18.195.246.16/udp/9090/webrtc-direct/certhash/uEiA8EDMfADmULSe2Bm1vVDSmN2RQPvY5MXkEZVOSyD1y2w/p2p/12D3KooWSmtsbL2ukwVwf8gDoTYZHnCd7sVNNVdMnCa4MkWjLujm" | ||
export const WEBRTC_BOOTSTRAP_NODE = "/ip4/192.168.44.145/udp/9090/webrtc-direct/certhash/uEiAj4WmbJoD2axUNfPT17inKyoruigvq-RxnlARLjeYnUQ/p2p/12D3KooWNrDx6wbjyUUjaZVAjmAnc1sFQJjig6z3GaE9N4jrvQnS" | ||
export const WEBTRANSPORT_BOOTSTRAP_NODE = "/ip4/3.125.128.80/udp/9095/quic-v1/webtransport/certhash/uEiAGIlVdiajNz0k1RHjrxlNXN5bb7W4dLPvMJYUrGJ9ZUQ/certhash/uEiDYZsZoO8vuTKlPhxvVR5SFwOkbXfjlsmTLUHNlnG24bg/p2p/12D3KooWEymoJRHaxizLrrKgJ9MhEYpG85fQ7HReRMJuEMLqmNMg" |
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