C .
ODE
G
AMELET
# 酷可的光暈戰記事件模組(TwilightWarsEventsCook) 用於擴充各種常用,但 [**TwilightWarsEvents**](https://code.gamelet.com/edit/TwilightWarsEvents) 沒有提供的動作、檢查、觸發。 因為 [**TwilightWarsEventsExp**](https://code.gamelet.com/edit/TwilightWarsEventsExp) 太髒太亂了,導致我自己開發新專案都不會用,所以打算重新弄一個乾淨的。 如專案標題所述,是我用來做給自己使用的,因此**破壞性更新是可能的!**如欲安裝請自行斟酌。 但由於開放源碼,所以萬一發生相關事件你也可以自己備份原始功能。 本專案有**大量中文註解**,如果你對於開發光暈戰記的新功能有興趣,可以查看原始碼來了解動作是怎麼運作的。 <font color=red>**注意!本模組可能與 [TwilightWarsEventsExp](https://code.gamelet.com/edit/TwilightWarsEventsExp) 存在部分衝突,如非必要不建議同時安裝兩個模組。**</font> ## 添加新功能的原則 - 必須基於 **TwilightWarsLib** 內有的功能衍生出來,如 `function`、`class` 等。 - 必須支援多人遊戲同步,沒有辦法在多人遊戲時,同步所有玩家狀態的功能不應該添加。 ## 玩家社群 ### Discord - [**嘎姆討論區**](https://discord.gg/hZKQzRfPJM):於 2021/05/08 創立的非官方社群,主要用於討論嘎姆擂台的相關資訊。 ## 作者 **酷可**:[**Code.Gamelet**](/profile/114899766849308759711@google)、[**Gamelet.Online**](https://gamelet.online/user/114899766849308759711@google/board)、[**Youtube**](https://www.youtube.com/@cook1470)
# P2P檔案分享 ## TL;DR EnhServer與TURN伺服器不會記錄你傳輸之資料,擔心隱私或資安問題請自行考慮後再決定是否使用本專案。 檔案最大應為 (2GiB - 2MiB) (已測試chrome/edge、firefox),若超過建議是採用壓縮檔分包個別傳輸。 註: - Windows的GB是GiB,即1024^3 Bytes - Linux的GB是1000^3 Bytes ## 使用須知 本專案使用WebRTC傳輸資料,藉由EnhServer協助使用者交換連線資訊,以順利建立連線。 本專案無需於EnhServer註冊帳號便可直接使用。 本專案由 **[雪姬](/profile/setsuki)** 提供STUN/TURNS伺服器,最大100Mbps總中轉頻寬。 伺服器可能並不算穩定,若有問題可至 [Discord 群組](https://discord.gg/seJwuzCbWq) 提醒我修復伺服器。 (TURNS為有加密之TURN伺服器,自建預設無加密,有需要可以使用ACME Client/Certbot向Let's encrypt申請證書以啟用加密) 若想要使用自有的STUN/TURN伺服器,請參閱 [Coturn Project on Github](https://github.com/coturn/coturn) 學習如何使用。 也可以自行建立自己的EnhServer,確保流量都可受自己控制,原始碼開源於 [EnhServer-monorepo on github](https://github.com/setsuk1/EnhServer-monorepo) 上。 ## 起因 有時想臨時分享檔案,但又擔心透過雲端硬碟傳遞資料沒有隱私。 因此建立起此專案,可以不讓第三方擁有自己的資料。 雖然也可透過EnhServer提供之訊息交換功能傳遞分塊。 但一來會對EnhServer的頻寬與記憶體帶來挑戰,二來則是瀏覽器端不便對資料進行處理。 再加上會帶來一些些複雜度,於是便透過WebRTC簡化這個流程。 ## 細節 (不關心可跳過) 首先先了解何為WebRTC。 WebRTC為於網路上實現之實時通訊。 需要兩類資料以建立連線:SDP資訊(offer/answer)與ICE資訊(IP、port、etc.) 首先使用者雙方須先交換SDP資訊,此部分如同連線之鑰匙與鎖,雙方不匹配就無法成功建立連線,該部分由EnhServer中轉。 當SDP交換完成時,雙方會各自向STUN/TURN伺服器取得可使用的連線資訊(ICE Candidate)。 之後會再透過EnhServer交換ICE資訊,並嘗試建立起連線。 而取得資訊可以透過兩類協議:STUN協議、TURN協議。 前者用來產生端到端連線,沒有任何中轉,但是對網路(NAT類型)有所要求。 後者則是透過一中轉伺服器轉發流量到對方一側,對NAT類型無要求,連線成功率提高許多,通常於STUN失敗時使用。 ## References MDN(Mozilla Developer Network Web docs) - **[RTCPeerConnection API](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection)** - **[RTCDataChannel API](https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel)** - **[RTCDataChannel Example](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Simple_RTCDataChannel_sample)** iT邦幫忙 - **[菜雞前端邁入網頁即時通訊(WebRTC)之旅](https://ithelp.ithome.com.tw/users/20129521/ironman/3138)** ## Authors **[雪姬](/profile/setsuki)** **[不會取名字](/profile/buhuechuminzu)**
# EnhServer 為了解決一些CG功能上的缺失,故實作此Lib。 包含變數無法跨專案使用,以及無法跨專案實作大聊天室。 (可能只是不知道方法) 未來將會逐步補上缺失的功能,範例後端請參照[此Github repo](https://github.com/setsuk1/EnhServer-monorepo),歡迎發起PR。 以及可以加入[Discord群組](https://discord.gg/seJwuzCbWq)一起討論,並共同討論功能方向。 初期可能不穩定,建議自建Server。 **且安全性並非此Lib的第一考量,此Lib主要是作為補充功能使用。** ## 如何使用 主要是透過下列方法進行初始化: ```typescript server.initialize(options) ``` options部分為可選選項,若參數為空則預設連線至Enh之後端伺服器。 預設狀態本模組會export一個server物件提供操作,若是希望使用多個instance,僅須透過下列方法: ```typescript const customServer = new EnhServer(); customServer.initialize(options); ``` 之後透過下列方式取得一對一傳訊的資料: ```typescript let context = { handler(data: any, senderCode: string) { console.log(data); } } server.msgManager.on(UserEventList.MSG.UNICAST, context.handler, context); ``` --- ## 呼叫功能 作為範例,下面舉出廣播至全體的功能如何使用: ```typescript let cmd = new Command(SocketEventList.USER, new BroadcastToAllEvent({ data: "Hi there." })); server.sendCommand(cmd); ``` 由此便可送出"Hi there."訊息到Server上的所有使用者。 至於其餘功能目前尚未確定如何說明,待補。 ## Authors **[EnhProject](/profile/EnhProject)** - **[不會取名字](/profile/buhuechuminzu)** - **[雪姬](/profile/setsuki)**
# TwilightWarsEventsEnhFF 本專案為 **TwilightWarsEventsEnh** 模組的 **beta版本** ,「FF」是「Fast Forward」的縮寫,代表快速開發。 因為原模組的開發緩慢,所以會逐漸把原模組的功能移植至本專案完善。 ## 前言 本專案主要由 **[雪姬](/profile/setsuki)** 維護。 歡迎加入 **[Discord群組](https://discord.gg/seJwuzCbWq)** 。 ## 使用須知 ***本專案開源,若有不明之處可查看 [test](cg://source/test/README.md)*** 本專案的主要目的是要讓事件表編輯如同寫程式一般。 不只專注於 **效能** ,會更著重在提供更大的 **彈性** 。 另外,本專案不會立即修復不嚴重的錯誤。 當測試穩定後,未來會將事件表功能從本專案移植回原模組,屆時該功能可能會在一段時間後,於本模組移除。 Enh的測試、回報需要你的參與,歡迎加入 **[Discord群組](https://discord.gg/seJwuzCbWq)** 。 ## 作者 **[EnhProject](/profile/EnhProject)** - **[不會取名字](/profile/buhuechuminzu)** - **[雪姬](/profile/setsuki)** --- # TwilightWarsEventsEnhFF "FF" stands for "Fast Forward", and can be considered as **beta version** of original **TWEventsEnh**. Due to slow updates of the original Enh, the functionality from mainline Enh would be porting and refined here. ## Additional This project is mainly maintained by [雪姬](/profile/setsuki). The **[Enh Discord server](https://discord.gg/seJwuzCbWq)** is also welcoming participants! ## Important ***It is recommanded to read source code and [test](cg://source/test/README.md) of this project!*** The main concept is to make events work as code. Not just focused on **performance**, but also provide more **flexibility**. This project will not repair bugs instantly unless they are critical. If there are any bugs, they will be fixed before integrated into the main Enh. Enh needs your participate for testing, asking questions or reporting bugs! Features merged into the mainline Enh will be removed here. ## Authors **[EnhProject](/profile/EnhProject)** - **[不會取名字](/profile/buhuechuminzu)** - **[雪姬](/profile/setsuki)**
ⒸCode.Gamelet.com | Privacy Policy | Terms of Service