我已经获得了一个带有支持 nodejs 的 cpanel 的共享主机。我可以通过“设置 Node.js 应用程序”定义一个 node.js 应用程序。
我想做一个websocket。他们已经为我打开了 2088 端口。
这是我的 websocket 服务器代码:
const http = require('http');
const WebSocket = require('ws');
const server = http.createServer();
const wss = new WebSocket.Server({ server });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
ws.send('something');
});
server.listen(2088);
Run Code Online (Sandbox Code Playgroud)
好吧,我运行我的代码,然后将此请求从客户端发送到服务器:
socket = new WebSocket('ws://mydomain.com:2088');
socket.addEventListener('open', function (event) {
socket.send('Hello Server!');
});
socket.addEventListener('message', function (event) {
console.log('Message from server ', event.data);
});
Run Code Online (Sandbox Code Playgroud)
但是,我不断收到超时错误,无法连接到 websocket 服务器。
似乎在共享 cpanel 主机上创建一个能够侦听特定端口的 websocket 服务器与通常的有点不同。
我已经浏览了互联网,我在 …
我想通过 php curl获取此页面的内容:
我的卷曲样本:
function curll($url,$headers=null){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
if ($headers){
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$response = curl_exec($ch);
$res['headerout'] = curl_getinfo($ch,CURLINFO_HEADER_OUT);
$res['rescode'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($response === false) {
$res['content'] = $response;
$res['error'] = array(curl_errno($ch),curl_error($ch));
return $res;
}
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$res['headerin'] = …Run Code Online (Sandbox Code Playgroud) 我想通过android意图打开特定电报联系人的聊天页面,例如@userTest。
这是意图打开的电报片段:
Intent myIntent = new Intent(Intent.ACTION_SEND);
myIntent.setType("text/plain");
myIntent.setPackage("org.telegram.messenger");
activity.startActivity(myIntent);
Run Code Online (Sandbox Code Playgroud)
但是现在如何打开特定用户的聊天页面?
根据bip39标准,我想从javascript中的助记词中获取种子。
我使用这段代码:
function mnemonicToSeed(mnemonic,passphrase){
if (typeof passphrase != 'string') passphrase='';
window.crypto.subtle.importKey(
'raw',
stringToArrayBuffer(mnemonic),
{
name: 'PBKDF2',
},
false,
['deriveKey']
).then((importedKey) => {
crypto.subtle.deriveKey({
name: "PBKDF2",
salt: stringToArrayBuffer('mnemonic'+passphrase),
iterations: 2048,
hash: { name: 'SHA-512' }
},
importedKey,
{
name: 'HMAC',
hash: 'SHA-512',
length: 512
},
true,
['sign']
).then(function(derivedKey) {
console.log('derivedKey: '+derivedKey);
});
});
}
Run Code Online (Sandbox Code Playgroud)
但最后的结果console.log('derivedKey: '+derivedKey);是这样的:
derivedKey: [object CryptoKey]
Run Code Online (Sandbox Code Playgroud)
现在如何将衍生密钥转换为其相应的种子作为十六进制字符串?
我想在点击按钮时增加当前窗口高度.
我用这个代码:
private void sendbtn_Click(object sender, RoutedEventArgs e)
{
DoubleAnimation myDoubleAnimation = new DoubleAnimation();
myDoubleAnimation.From = this.Height;
myDoubleAnimation.To = 500;
myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.5));
Storyboard myStoryboard = new Storyboard();
myStoryboard.Children.Add(myDoubleAnimation);
Storyboard.SetTargetName(myDoubleAnimation, this.Name);
Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Window.HeightProperty));
myStoryboard.Begin(this);
}
Run Code Online (Sandbox Code Playgroud)
但我想在xaml中声明我的故事板并从代码中运行它.
但我不知道这是怎么回事?
我在 windows cmd 中使用此命令在 Chocolatey 上启用了显式代理:
choco config set proxy http://localhost:8888
Run Code Online (Sandbox Code Playgroud)
现在我想禁用它,但不知道如何。
brotli ×1
c# ×1
chocolatey ×1
compression ×1
cpanel ×1
cryptography ×1
curl ×1
javascript ×1
node.js ×1
passenger ×1
php ×1
proxy ×1
telegram ×1
websocket ×1
wpf ×1
xaml ×1