|
|
|
@ -2,7 +2,7 @@ import React, { Component, useState } from 'react' |
|
|
|
import {View, Text} from '@tarojs/components' |
|
|
|
import {View, Text} from '@tarojs/components' |
|
|
|
import { Progress } from '@nutui/nutui-react-taro'; |
|
|
|
import { Progress } from '@nutui/nutui-react-taro'; |
|
|
|
import { Form, Input, TextArea, Cell, Button, Row, Col, Image } from '@nutui/nutui-react-taro'; |
|
|
|
import { Form, Input, TextArea, Cell, Button, Row, Col, Image } from '@nutui/nutui-react-taro'; |
|
|
|
import { message } from '../../compiled' |
|
|
|
import { api } from '../../proto' |
|
|
|
|
|
|
|
|
|
|
|
import './login.scss' |
|
|
|
import './login.scss' |
|
|
|
|
|
|
|
|
|
|
|
@ -16,7 +16,7 @@ function Login(props, ref) { |
|
|
|
// console.log(buffer) |
|
|
|
// console.log(buffer) |
|
|
|
// let decoded = message.Proto.decode(buffer); |
|
|
|
// let decoded = message.Proto.decode(buffer); |
|
|
|
// console.log(decoded) |
|
|
|
// console.log(decoded) |
|
|
|
// console.log(message) |
|
|
|
console.log(api) |
|
|
|
|
|
|
|
|
|
|
|
const [state, setState] = useState({ |
|
|
|
const [state, setState] = useState({ |
|
|
|
username: '', |
|
|
|
username: '', |
|
|
|
@ -39,6 +39,31 @@ function Login(props, ref) { |
|
|
|
} |
|
|
|
} |
|
|
|
const handleSubmit = () => { |
|
|
|
const handleSubmit = () => { |
|
|
|
console.log('submit', state) |
|
|
|
console.log('submit', state) |
|
|
|
|
|
|
|
// websocket test |
|
|
|
|
|
|
|
const ws = new WebSocket("ws://localhost:9999/ws") |
|
|
|
|
|
|
|
ws.binaryType = 'arraybuffer' |
|
|
|
|
|
|
|
ws.onopen = (e) => { |
|
|
|
|
|
|
|
// 连接后立即认证连接 |
|
|
|
|
|
|
|
const token = "AgOjcdf3goeYDX3lwWWwkXtVpcrL-l2rX8csrRKgs3_-BC3JOx0l6nZU0MV25eIn" |
|
|
|
|
|
|
|
const req = api.ReqIdentity.create({token}) |
|
|
|
|
|
|
|
const reqBuffer = api.ReqIdentity.encode(req).finish() |
|
|
|
|
|
|
|
const wrap = api.ProtoWrap.create({ver:1, op: 13578 + 3, seq:1, body: reqBuffer}) |
|
|
|
|
|
|
|
const wrapBuffer = api.ProtoWrap.encode(wrap).finish() |
|
|
|
|
|
|
|
ws.send(wrapBuffer) |
|
|
|
|
|
|
|
console.log('send', req, wrap) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ws.onmessage = (e) => { |
|
|
|
|
|
|
|
console.log('msg:', e.data) |
|
|
|
|
|
|
|
const wrap = api.ProtoWrap.decode(new Uint8Array(e.data)) |
|
|
|
|
|
|
|
const res = api.ResIdentity.decode(wrap.body) |
|
|
|
|
|
|
|
console.log(wrap.op, res) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ws.onerror = (a,b,c) => { |
|
|
|
|
|
|
|
console.log('error:', a, b, c) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ws.onclose = e => { |
|
|
|
|
|
|
|
console.log('close', e) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<View className='login'> |
|
|
|
<View className='login'> |
|
|
|
|