homepage: https://github.com/Lupino/metro#readme
changelog-type: markdown
hash: 4390ccc315d5b89c1c1b7beecacaf5e0dcca13d2e6750ac3b65c8ea38b994102
test-bench-deps: {}
maintainer: lmjubuntu@gmail.com
synopsis: A simple tcp and udp socket server framework
changelog: |
  # Changelog for metro

  ## Unreleased changes
basic-deps:
  bytestring: -any
  unix-time: -any
  unliftio: -any
  base: '>=4.7 && <5'
  unordered-containers: -any
  binary: -any
  hslogger: -any
  mtl: -any
  hashable: -any
  transformers: -any
all-versions:
- 0.1.0.0
author: Lupino
latest: 0.1.0.0
description-type: markdown
description: |
  # 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 CustomPacket

  sessionHandler = 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
license-name: BSD-3-Clause

Update from Hackage at 2020-08-09T02:12:00Z
Update from Hackage at 2020-08-09T02:12:00Z
