Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lupino/metro
a simple tcp and udp socket server framework
https://github.com/lupino/metro
Last synced: about 1 month ago
JSON representation
a simple tcp and udp socket server framework
- Host: GitHub
- URL: https://github.com/lupino/metro
- Owner: Lupino
- License: mit
- Created: 2019-07-24T02:51:21.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-19T02:57:28.000Z (8 months ago)
- Last Synced: 2024-10-28T14:18:28.335Z (2 months ago)
- Language: Haskell
- Homepage:
- Size: 179 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
# metro
a simple tcp and udp socket server framework
## Quick start with example
```haskell
import Metro.Class
import Metro.Node
import Metro.TCP
import Metro.Servable
import Metro.Session (SessionT, makeResponse_)data CustomPacket = CustomPacket { ... }
type CustomPacketId = ...instance RecvPacket CustomPacket where
recvPacket recv = ...
instance SendPacket CustomPacket where
sendPacket pkt send = ...instance GetPacketId CustomPacketId where
getPacketId = ...
instance SetPacketId CustomPacketId where
setPacketId k pkt = ...type NodeId = ...
data CustomEnv = CustomEnv { ... }
type DeviceT = NodeT CustomEnv NodeId CustomPacketId CustomPacket
type DeviceEnv = NodeEnv1 CustomEnv NodeId CustomPacketId CustomPacketsessionHandler = makeResponse_ $ \pkt -> ...
sessionGen :: IO CustomPacketId
sessionGen = ..prepare :: Socket -> ConnEnv tp -> IO (Maybe (NodeId, CustomEnv))
prepare sock connEnv = Just ...keepalive = 300
bind_port = "tcp://:8080"
startExampleServer = do
sEnv <- initServerEnv "Example" (tcpConfig "tcp://:8080") sessionGen rawSocket prepare
void $ forkIO $ startServer sEnv sessionHandler
```more see [metro-example/src/Metro/Example.hs](https://github.com/Lupino/metro/tree/master/metro-example/src/Metro/Example.hs)
## Projects use metro
- [haskell-hole](https://github.com/Lupino/haskell-hole) A hole to pass through the gateway. haskell version
- [metro-example](https://github.com/Lupino/metro/tree/master/metro-example) An example use metro
- [haskell-periodic](https://github.com/Lupino/haskell-periodic) Periodic task system haskell client and server