小编Fab*_*Pas的帖子

在Java中同时做两件事

好吧,我正在开发一个Java在线游戏.我有一个客户端和一个服务器.并且语音系统等待显示如下的新消息:

public void addSpeech(String msg) {
    String newMsg = parsel10n(msg);
    m_narrator.addSpeech(parsel10n(newMsg));
    while (!m_narrator.getCurrentLine().equalsIgnoreCase(newMsg))
      ;
    while (!m_narrator.getAdvancedLine().equalsIgnoreCase(newMsg))
      ;
 } 
Run Code Online (Sandbox Code Playgroud)

问题是..由于while循环,应用程序的其余部分停止.在这个循环中,我没有看到任何其他玩家移动或看到聊天.有没有办法我可以运行这个方法而不用循环接触应用程序(客户端)的其余部分?应该涉及线程吗?我希望你能回答我.

java

3
推荐指数
1
解决办法
209
查看次数

正则表达式:未知修饰符 '\'

我有以下正则表达式:

(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))
Run Code Online (Sandbox Code Playgroud)

但它给了我以下错误:

Unknown modifier '\'
Run Code Online (Sandbox Code Playgroud)

我尝试像这样转义反斜杠:

(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))
Run Code Online (Sandbox Code Playgroud)

没有任何运气......我也尝试用波浪号替换反斜杠,再次没有运气。我已经在互联网和 SO 上搜索了有关“\”作为未知修饰符的任何详细信息,但再次没有运气。这里出了什么问题?

应要求提供的代码示例:

$regex = '(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'\".,<>?«»“”‘’]))';
return !preg_match($regex, $url);
Run Code Online (Sandbox Code Playgroud)

谢谢!

php regex preg-match

3
推荐指数
2
解决办法
1846
查看次数

将十进制字符串解析为字节

我在将十进制字符串解析为字节时遇到问题。

这是带有位置数据的数组,通常是整数。但是我已经能够创建一种位置数据为小数的情况,这会使服务器崩溃,因为似乎无法解析它。

string[] locationData = Request.Content.Split(' ');
int itemID = int.Parse(locationData[0]);
byte newX = byte.Parse(locationData[1]);
byte newY = byte.Parse(locationData[2]);
Run Code Online (Sandbox Code Playgroud)

这行代码给我一个错误,提示输入格式不正确:

byte newX = byte.Parse(locationData[1]);
Run Code Online (Sandbox Code Playgroud)

我一直在尝试使用Math.Round而不成功。我确实认为我必须舍入小数点,因为我正在检索X和Y来放置家具单元。

同样,locationData [1] = 6.0000的内容,这是它试图解析的数字/字符串。

我似乎无法解决问题,希望您能有所帮助。

c#

2
推荐指数
1
解决办法
495
查看次数

Laravel路由用nginx覆盖phpmyadmin路径

我的LEMP Droplet上有以下nginx配置:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /var/www/html/public;
    index index.php index.html index.htm;

    server_name server_domain_or_IP;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}
Run Code Online (Sandbox Code Playgroud)

我想在/ phpmyadmin上与Laravel一起运行PHPMyAdmin,但只有Laravel路由才能提供给浏览器.所以任何/ phpmyadmin都会被解析为不是一个的路由.

我尝试了很多东西

  • 添加我自己的位置/phpmyadmin上面location ~ \.php甚至还试图^~ /phpmyadmin迫使优先.

  • 我将我的根设置为/ usr/share/phpmyadmin,没有任何结果.

  • 我试过复制fastcgi选项,基本上复制完整的逻辑,但使用/ phpmyadmin也没有任何结果

我很确定这可能是我遗失的一件小事.

ubuntu nginx laravel

2
推荐指数
1
解决办法
3651
查看次数

Caliburn Micro未在ListView中的ContextMenu中找到DataContext

我用对象填充了ListView,并将ContextMenu绑定到ListView中的那些项目.只能通过单击项目来打开ContextMenu.问题是Caliburn Micro抛出一个错误,它无法找到ShowProperties()的目标方法.

我认为出现此问题是因为Caliburn没有可用的ViewModel的正确DataContext.我在Stackoverflow上尝试了很多解决方案,使ViewModel可用于ContextMenu项目,但无济于事,例如:

WPF:将ContextMenu绑定到MVVM命令

Caliburn Message.Attach()抛出"找不到方法的目标"

Caliburn Micro中的WPF上下文菜单

这是我的观点的XAML代码:

<Window x:Class="CueMaster.Views.AppView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:dragDrop="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
         xmlns:cal="http://www.caliburnproject.org"
         Height="500" Width="800">
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="200" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>

    <ListView Grid.Column="1" Margin="5"
        ItemsSource="{Binding Cues}" 
        dragDrop:DragDrop.IsDragSource="True" 
        dragDrop:DragDrop.IsDropTarget="True"
        dragDrop:DragDrop.DropHandler="{Binding}">

        <ListView.Resources>
            <ContextMenu x:Key="ItemContextMenu">
                <MenuItem Header="Properties" cal:Message.Attach="ShowProperties($dataContext)" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}}">
                    <MenuItem.Icon>
                        <Image Source="../PropertyIcon.png" />
                    </MenuItem.Icon>
                </MenuItem>
            </ContextMenu>
        </ListView.Resources>

        <ListView.ItemContainerStyle>
            <Style TargetType="{x:Type ListViewItem}" >
                <Setter Property="ContextMenu" Value="{StaticResource ItemContextMenu}" />
            </Style>
        </ListView.ItemContainerStyle>

        <ListView.View>
            <GridView >
                <GridViewColumn Width="70" Header="Cue"  DisplayMemberBinding="{Binding Id}" />
                <GridViewColumn Width="100" …
Run Code Online (Sandbox Code Playgroud)

c# wpf mvvm caliburn.micro

2
推荐指数
1
解决办法
1222
查看次数

标签 统计

c# ×2

caliburn.micro ×1

java ×1

laravel ×1

mvvm ×1

nginx ×1

php ×1

preg-match ×1

regex ×1

ubuntu ×1

wpf ×1